How to iterate through a tree in a spiral?
2 answers
This is really a variation of Breadth First Search. Breadth First Search uses a queue to get a list of nodes on the next level down. The queue is FIFO (first first). If you change the order at each level, you get this effect, so you need LIFO (the last one in the first), otherwise known as a stack.
+1
a source to share