// TOPIC

#trees

11 articles

Beginner
01

Trees: When Data Branches

Move beyond flat lists and discover why trees power everything from file systems to databases. Learn nodes, roots, leaves, height, and how a balanced tree buys you O(log n) on a silver platter.

#trees#data-structures#fundamentals
10 min
◆◆IntermediateGoogleAmazon
02

Union-Find (Disjoint Set Union)

Union-Find (disjoint set union) answers 'are these two nodes connected?' in near-constant time. Master path compression, union by rank, and Kruskal's MST.

#union-find#disjoint-set-union#graphs
12 min
◆◆IntermediateGoogleAmazon
03

Tries (Prefix Trees)

How tries (prefix trees) power autocomplete and spell-check — insert, search, and prefix queries all run in O(L) on word length, not dictionary size.

#tries#trees#strings
12 min
◆◆◆AdvancedGoogleMeta
04

Segment Trees

Segment trees answer range queries AND handle point or range updates in O(log n) — the structure to reach for when prefix sums aren't enough and you need both reads and writes at scale.

#segment-trees#trees#range-queries
13 min
◆◆◆AdvancedGoogle
05

Fenwick Trees (Binary Indexed Trees)

Fenwick trees deliver O(log n) prefix sums and point updates in ~10 lines of code. Master the lowbit trick and know when a BIT beats a segment tree.

#fenwick-tree#binary-indexed-tree#prefix-sums
15 min
◆◆◆AdvancedGoogleAmazon
06

Balanced BSTs (AVL & Red-Black Trees)

Balanced BSTs keep height O(log n) on any insert order. See how AVL and red-black rotations work, and why Java TreeMap and C++ std::map run on them.

#trees#binary-search-trees#balanced-trees
14 min
◆◆IntermediateAmazonGoogle
07

Heaps and Priority Queues

Learn how the heap data structure delivers O(1) peek and O(log n) push and pop — the engine behind priority queues, top-K queries, and K-way merges.

#heaps#trees#priority-queues
11 min
◆◆IntermediateAmazonMeta
08

Binary Trees and Traversals

Master binary tree traversal — inorder, preorder, postorder, and level-order — and the recursive mindset that makes dozens of tree problems click instantly.

#trees#binary-trees#traversals
12 min
◆◆IntermediateAmazonGoogle
09

Binary Search Trees

The left<node<right invariant gives you O(log n) search, insert, and delete — until the tree degenerates into a linked list. Here's the full picture, including why inorder traversal is a free sort.

#trees#data-structures#binary-search
11 min
◆◆IntermediateAmazonGoogle
10

DFS Patterns

Depth-first search is the backbone of cycle detection, flood fill, path enumeration, and clone graph — master the visited-set template, the 3-color trick, and when to reach for DFS over BFS.

#graphs#dfs#traversal
14 min
◆◆IntermediateAmazonGoogle
11

BFS Patterns

Queue-driven level-by-level traversal and why breadth-first search is the only guaranteed way to find shortest paths in unweighted graphs. Templates, traps, and four worked problems.

#graphs#bfs#traversal
13 min