| Multiple stacks : | |||||||||||||||
ALGORITHM FOR ADDITION(PUSH) AND DELETION(POP) OF ITEMS |
|||||||||||||||
| push ( item,array,n,top) | pop (item,stack,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-- ; | |||||||||||||||
| array[top]=item; | |||||||||||||||
| } | } | ||||||||||||||
| } | |||||||||||||||
| } | |||||||||||||||
| Visual idea of Push Operation | Visual idea of Pop Operation | ||||||||||||||
| Prev | |||||||||||||||