in reply to Binary tree without recurssion

Depth first traversal can be accomplished with an array and unshift, breadth-first search via an array and push. Following pseudo-code converts to a flat list:

# -*- pseudo-mode -*- traverse_queue = [ root ]; work_queue = []; while ( work_queue is_not empty ) { node = shift( traverse_queue ); push( work_queue, node ) if BFS; push/unshift( traverse_queue, children ); push( work_queue, node ) if DFS; }

--MidLifeXis