Tag: #stack
How to sort a stack using one additional stack
We can model “infinite tape” using two stacks. Then we can navigate the list in both directions. This lets us bubble-sort the list in O(n^2) time. 2020-01-22
Implementing a queue using two stacks
Implement a queue using two stacks, with one stack for the back of the queue and one for the front. Reverse the back stack onto the front stack when dequeuing to maintain the queue order. 2020-01-21
All content copyright James Fisher.