Btree traversal is obvious to implement in recursion. here are non-recursion implementation, which needs std::stack
or std::queue
data structure to store the next level nodes in both deep-first-search idea and breadth-first-search idea, link. these are good examples of using stack, queue.
usage in leetCode114, flatten a BTree to a linked list
|
|