Iteratively preorder
Anonymous
iterativePreorder(node) parentStack = empty stack parentStack.push(null) top = node while ( top != null ) visit( top ) if ( top.right != null ) parentStack.push(top.right) if ( top.left != null ) top = top.left else top = parentStack.pop();
Check out your Company Bowl for anonymous work chats.