Begin Algo
Data structures · 7 lessons

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 up
File systems and the DOM

Folders inside folders, tags inside tags. Computing a folder's size, rendering a page, serialising JSON — all tree traversal.

→ Lesson: Traversal
Database indexes and sorted sets

A 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: BST
Autocomplete in a search box

Type "alg" and "algorithm" appears. A trie walks letter by letter, one level per character.

→ Lesson: Trie
Live rankings and range statistics

A 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

Lessons

7 lessons