What is Stack
Stack is a linear type data structure that follows LIFO (last in, first out) system. The system implies that the last item inserted into a stack is the first item to be removed.
Implementation of Stack in Real Life
Many real-life examples of a stack, an example is a stack of plates. When you clean dirty plates, you will pick the top plate.
Stack Operations
Generally, there are 6 operations in Stack data structure:
1. Push
Push is the operation of inserting an item into a stack.
2. Pop
Pop is the operation of removing the top-most item from a stack.
3. Peek
Peek is the operation of peeking the top-most item of a stack without removing it.
4. Is Empty
Is Empty is the operation to check if the stack is empty or not.
5. Is Full
Is Full is the operation to check if the stack is full or not.
6. Size
Size is the operation to get the size of the stack.
There you go, it is a little introduction from me about stack data structure. Next post, I will begin to implement it to a programming language. Thank you for reading this article, and stay tune!
Top comments (0)