A pile you only touch at the top: push puts a value on top, pop takes the top one off. Backed by an array, the top is just an index, so both are a single step.
- Typical operation
- O(1)
- Space
- O(n)
A pile you only touch at the top: push puts a value on top, pop takes the top one off. Backed by an array, the top is just an index, so both are a single step.