Trees
Tree vocabulary, binary trees, traversal orders and recursive tree problems.
- Trees: root, leaf, depth, height, subtree A tree has a root, children, leaves, depth and height. Hover over a tree to see each term and measure depth with rulers.
- Binary trees and how they are stored In a binary tree each node has at most a left and a right child. See nodes as objects with references, and complete trees stored in an…
- Pre-order, in-order, post-order Pre-order, in-order and post-order visit a tree’s nodes in different orders. Watch visit numbers appear while the call stack grows beside…
- Level-order traversal Level-order traversal visits a tree one level at a time using a queue. Watch the queue fill with each level’s children.
- Recursive problems on trees: height, size, mirror, paths Height, size, mirror images and path sums all follow one pattern: solve both subtrees, then combine at the node. Watch values bubble up to…
- Serialization and construction Serialization turns a tree into a string and back. Watch tokens emitted on the way out and consumed to rebuild the same tree.