## In this tutorial, we learn Stack Data structure with Push, Pop and Display Operations. Data structure follows a particular order in which the operations are performed.

### What is Stack?

Stack is a linear data structure in which objects are just like a pile of the CD on CD spindle(whose one end is closed and other is open) kept on top of each other.

Think about the things you can do with such a pile of CD:

- Put a new CD on top
- Remove the CD plate

The insertion(PUSH) and deletion(POP) operation occur only at one end of the stack. Stack work on LIFO(Last IN first OUT) order the element which is at the top will delete first and top pointer represent the last element of the stack.

Below is a simple representation of a stack with PUSH and POP operations:

## Operations on the stack:

- PUSH(Insertion): If the top of the stack at top=n-1, where n=size of the stack then the stack is overflow and insertion is not possible. If the stack does not overflow then the pointer top is firstly incremented by one or top=top+1, and then the element is inserted.
- POP(Deletion): If the top of the stack at top=-1, then the stack is underflow and deletion is not possible. If the stack does not underflow then print the deleted element to know which element is deleted from a stack, and then top=top-1.
- Display: Display is possible when any element present in the stack or top!=-1 and not possible if the stack is empty.

### Stack data structure with push, pop and Display Operations program

NOTE: If you have any problem in Algorithm and Program for PUSH and POP Operations than comment on your problem.

Happy Coding !!

## 0 Comment to "Algorithm and Program for PUSH and POP Operations"

## Post a Comment