| Push and Pop : | ||||||||||||||||
Algorithms |
||||||||||||||||
| Push (item,array , n, top) | Pop (item,array,top) | |||||||||||||||
| { | { | |||||||||||||||
| if ( top<= 0) | ||||||||||||||||
| If ( n> = top) | ||||||||||||||||
| Then print " stack is empty". | ||||||||||||||||
| Then print "Stack is full" ; | ||||||||||||||||
| Else | ||||||||||||||||
| Else | ||||||||||||||||
| { | { | |||||||||||||||
| item = array[top]; | ||||||||||||||||
| top = top + 1; | ||||||||||||||||
| top = top – 1; | ||||||||||||||||
| array[top] = item ; | ||||||||||||||||
| } | } | |||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| Visual idea of Push Operation | Visual idea of Pop Operation | |||||||||||||||
| Prev | ||||||||||||||||