Stack

Stack

Stack

Stack is an ordered collection of items into which new items may be inserted or deleted at one end of the stack called top

Stack follow LIFO [Last In First Out ]. That is the element to be deleted first is the one which is  inserted last. Stack is also called a push down list

Operations on Stack

       1. PUSH
                Inserting an element on the top of the stack

        2. POP
                  Remove the top element

        Empty (S)  : check whether stack is empty or not
 
        Stacktop(S)   : returns the top element

 


Convert Infix into Prefix and Postfix

Infix                   Prefix                        Postfix

( A+B) * C              * + ABC                          AB+C*

  A+ (B*C)               +A*BC                            ABC*+

(A+B) / ( C- D)          / + AB -  CD                AB+CD - /

A-B / ( C*D  $ E )      - A / B*C $ D E            ABCDE$ * / -