Sunday, March 15, 2020

Stack & Queue


Operator is written between operandsIn this material we will learn about how data are stored(stack & queue) and notations(Infix, Postfix, Prefix).
  • Stack Concept
    • Basically, the data are stored like stacked objects. We insert the object to the last, and the last will be taken first. This is also known as LIFO (Last in First Out).
    • Stack Operations:
      • push(x) : add an item x to the top of the stack.
      • pop() : remove an item from the top of the stack.
      • top() : reveal/return the top item from the stack.
  • Queue Concept
    • Queue concept is just like the stack concept but this time the first one will be taken first. This is also known as  FIFO (First In First Out).
  • Infix, Postfix, Prefix Notations.
    • Based on how operator is written, there are 3 methods in inserting data:
      • Infix
        • Operator is written between operands.
      • Postfix
        • Operator is written after operands.
      • Prefix
        • Operator is written before operands.

0 comments:

Post a Comment