Inorder Tree Walk
What does the following code do?
TreeWalk(x)
TreeWalk(left[x]);
print(x);
TreeWalk(right[x]);
A: prints elements in sorted (increasing) order
This is called an inorder tree walk
- Preorder tree walk: print root, then left, then right
- Postorder tree walk: print left, then right, then root