Stack is another data structure like queue, also the stack is ordered list like queue. The difference is stack allows addition and deletion of items at one end only. This end is called bottom of stack and inactive end is called bottom of stack. The slices of bread is a daily life example for stack. We are usually takes bread from one end and places the bread at same end. So we can say that the stack follows LIFO(Last In First Out) principle.
http://www.visualphotos.com/image/2x3535478/stack_of_sliced_bread |
We can perform two operations on stack. They are,
- PUSH: Addition of new item.
- POP: Deletion of item.
The stacks have important data structure in computer. They are applied in evaluation of mathematical expressions, execution of programs, etc.