二叉树的遍历分为深度优先遍历(Depth First Traversal)和广度优先遍历(Breath First Traversal also called Levelorder Traversal)。其中深度优先遍历又分为先序遍历(Preorder Traversal),中序遍历(Inorder Traversal)和后续遍历(Postorder Traversal)。
Pre-order Traversal
Visit the root, traverse the left subtree, traverse the right subtree.
- recursive
- stack
In-order Traversal
Traverse the left subtree, visit the root, traverse the right subtree.
- recursive
- stack
Post-order Traversal
Traverse the left subtree, traverse the right subtree, visit the root.
- recursive
- stack
网友评论