Preorder Traversal
Write the node down first, then walk its left subtree and then its right.
Tree Traversals: Preorder, node before subtrees
50 is the root, and preorder writes a node down before going anywhere.
Cost
- Best
- O(n)
- Average
- O(n)
- Worst
- O(n)
- Space
- O(h)
Before this
Related
Leads to
Topics that need this one first.
Taught by the same lesson
Tree Traversals covers these too, in the same run.