Queues, Sorting and Tower of Hanoi