Tree Height
left -> root -> right
root -> left -> right
Derived DFS.
left -> right -> root
Derived DFS.
Traverse the tree one layer at a time
3
/ \
9 20
/ \
15 7
------------
[
[3],
[9, 20],
[15, 7]
]
This is similar to Bread-first Search. The trick is to use a queue, and iterate the length of the queue to store each layer node.