S T  A C K Based on Chapter 3 Of  Reference Book #1
Reference Books Data Structures and Algorithm Analysis in C By Mark Allen Weiss Published by Addison Wesley Data Structures (Schaum’s Outline Series) By Seymour Lipschutz  Published by Mc Graw Hill
A STACK Model Definitions A  STACK  is a list with the restriction that insertion and deletion can be performed in only one position.for that reason it is called  LIFO  (last in first out ) structure. The end where insertion and deletion can be performed is called the end of the list or  top. Set of operations PUSH , i nserts  a new element at the end or   top . POP ,  deletes  or remove most recently inserted element from  top. TOP,  retrieves   most recently inserted element from  top. isEmpty ,  returns the status of emptiness of the stack. A  pop  operation on top on an empty stack is considered as an error. A  push  on a full stack cause a  overflow  condition.
Stack Model
Implementation As Linked List PUSH = insertion at front of the list. POP = retrieving and deletion at the front of the list TOP = retrieving the value of the front node
Linked List implementation Declarations
Linked List implementation Empty Test Create Stack
Linked List implementation PUSH TOP
Linked List implementation POP
Implementation As Array Define an Array ‘ Stack ’ of sufficient capacity to store stack elements. Uses a variable i.e  TopOfStack  to remember the position of TOP. TopOfStack  = -1 for an empty stack. PUSH: Set  TopOfStack = TopOfStack +1 Set  Stack[TopOfStack] = X POP: Return  Stack[TopOfStack] Set  TopOfStack = TopOfStack –1
Array implementation Declarations
Array implementation Create Stack
Array implementation Free the  Stack Check for Empty stack
Array implementation Empty the  Stack PUSH
Array implementation TOP POP TOP and POP
Applications Postfix Notation
Applications Postfix Notation 6 5 2 3 + 8 * + 3 + *
Applications Postfix Notation 6 5 2 3 + 8 * + 3 + *
Applications Postfix Notation 6 5 2 3 + 8 * + 3 + *
Applications Infix to Postfix a + b * c + ( d * e + f ) * g
Applications Infix to Postfix a + b * c + ( d * e + f ) * g
Applications Infix to Postfix a + b * c + ( d * e + f ) * g
Applications Infix to Postfix a + b * c + ( d * e + f ) * g
Applications Infix to Postfix a + b * c + ( d * e + f ) * g
Applications Infix to Postfix a + b * c + ( d * e + f ) * g
Applications Infix to Postfix a + b * c + ( d * e + f ) * g
Applications Infix to Postfix a + b * c + ( d * e + f ) * g
Applications Infix to Postfix a + b * c + ( d * e + f ) * g  Function Calls ( another application )
a + b * c + ( d * e + f ) * g  Infix to Postfix a + b * c + ( d * e + f ) * g a + b * c + ( d * e + f ) * g + * + ( * + ) *

Stack