Tag: #algorithms
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
Implementing a queue using a linked list
The head is the front of the queue, allowing efficient dequeue. The tail is the back of the list. To enqueue efficiently, we keep a reference to the tail. 2020-01-18
Determine if a string has all unique characters
A recursive algorithm to determine if a string has all unique characters, with an analysis of its time complexity. 2020-01-04
All content copyright James Fisher.