Stack algorithm

Stack operation :-this is two operation performed 

  • Push :- (insert an element) 
  • Pop :-(delete an element)
// Simple algorithm for push & pop.
          Push                                                  pop
 Push(stack, top, maxstack,     pop(stack, top, Item).                                                        Item)
if(top=maxstack)                 if(top=0)
     { then                                        { "underflw" 
         "overflow" return.                   return
        }                                                   } 
Else  {top=top+1.              else{item=stack[top] 
         Stack[top] =item.             top=top-1
           }                                                  } 

Comments

Post a Comment