Python
The stack data structure allows us to place any programming artifact, variable or object on it.
Its almost similar to a physical stack.
Push
- Used to insert elements to a stack
- After pushing an element to a stack the new element becomes the top element.
Pop
- Used to remove elements from a stack.
- Uses First-in Last-out property, which means the top element , the last to be inserted is removed when the pop operation takes place.
NB: Pop and push are the most fundamental operations to be used in stacks.
Peek
- Used to return the top element.
- Helps to check whether the stack is empty or other things that may come up.