Download Linked List implementation of Stack : [wpdm_package id=’1328′]
Download Array implementation of Stack : [wpdm_package id=’1331′]

Stack is a linear list of elements for which insertions and deletions are made at only one end of the list. Stack data structure follow Last in First out(LIFO) strategy, it means that we can pop or remove only the last inserted element in the list. We can’t pop the elements from in between the list.
The following operations are possible in the Stack data structure –
1. IsEmpty() – returns weather the stack is empty or not
2. Size() – returns the size of the stack (number of elements in stack)
3. Push(int el) – insert the element el into the stack
4. Pop() – pop(removes) an element from top of stack
5. Top() – display the last inserted element in the stack

All the above mentioned operations are of O(1) time complexity.

Leave a Reply

Your email address will not be published. Required fields are marked *