TreeHierarchies without cycles
A tree is "a node with more nodes under it", which maps onto recursion directly. Start with traversing a binary tree; binary search trees combine order with dynamic insertion; tries handle strings; segment trees and Fenwick trees handle range queries.
Why learn Tree
Where it shows upFolders inside folders, tags inside tags. Computing a folder's size, rendering a page, serialising JSON — all tree traversal.
→ Lesson: TraversalA MySQL index is a B-tree; Redis sorted sets and Java's TreeMap are balanced search trees. "Find it fast and keep it in order" is the BST family's job.
→ Lesson: BSTType "alg" and "algorithm" appears. A trie walks letter by letter, one level per character.
→ Lesson: TrieA hundred thousand values changing constantly, and you still need "the sum of entries 1000 to 2000". Segment trees and Fenwick trees keep both query and update logarithmic.
→ Lesson: Segment Tree