Tag: Binary Tree Traversal
-
Algorithms 101: Non-Recursive Binary Tree Traversal
•
Non-Recursive Binary Tree Traversal by 砖家王二狗 In-order Traversal: In in-order traversal, we visit the left subtree, then the root, and finally the right subtree. Here’s a non-recursive example in Python: def in_order_traversal(root): result = [] stack = [] current = root while current or stack: while current: stack.append(current) current =…