Stack Using Array Algorithm
Stack Using Array Algorithm
Push()
Step 1:If (top <= -1) otherwise goto step 5
Step 1.1:Print “Stack Overflow” and return.
Step 2:Otherwise
Step 2.1:read value.
Step 2.2:Increase the top value.
Step 2.3: stack[top]x.
Step 3:End of push method().
Pop()
Step 1:if (top <= -1) else goto step 2
Step 1.1:print"Stack Underflow" message and return.
Step 2:Otherwise:
Step 2.1:Pop the stack[top] and decrement top
Step 2.2:print the deleted element
Step 3 :End of pop method().
Display()
Step 1:initialize i=top
Step 2:if (i>=0) otherwise goto step 3
Step 1.1: print stack[i]
Step 1.2 decrement i value goto step 2
Step 3: print"Stack is empty"
Step 4: end of display() method.