Stacks
Stacks
1. Introduction
A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. The element
that is inserted last is the first to be removed. It is comparable to a stack of plates — you add to
the top and remove from the top.
2. Basic Operations
Operation Description
3. Implementation
python
CopyEdit
stack = []
# Push elements
stack.append(10)
stack.append(20)
# Pop element
stack.pop() # Output: 20
empty = len(stack) == 0
5. Applications