
What Is a Sparse Table? The O(1) Range Minimum Query Algorithm
Sparse table algorithm: O(n log n) build, O(1) range minimum queries. 14 implementations, complexity analysis, and when to use it over a segment tree.
Page 17 of 61 · Ideas for curious minds in tech.
Back to the archive
Sparse table algorithm: O(n log n) build, O(1) range minimum queries. 14 implementations, complexity analysis, and when to use it over a segment tree.

A Fenwick tree (binary indexed tree) delivers O(log n) range sum queries and point updates in 15 lines of code. Here's how the bit trick works.

Segment trees answer range queries and point updates in O(log n). What is a segment tree, how it works, and the interview patterns you need to know.

A suffix array enables O(m log n) suffix array search after a single build pass. Learn binary search over suffixes, LCP arrays, and build algorithms.

What is a suffix tree? It turns one O(n) build into O(m) per query. Learn the structure, Ukkonen's algorithm, and why suffix arrays win in practice.

Learn what a trie is, how the prefix tree works, and when to reach for it in coding interviews. O(m) operations, space trade-offs, LeetCode patterns.

A B+ tree stores all data in its leaves linked as a list, powering O(log n + k) range queries and every major database index. Here's how.

A B-tree data structure finds records in a billion-row database with 3 disk reads. How it works, why databases use B+ trees, and what interviews test.

Red-black trees are self-balancing BSTs that guarantee O(log n) lookups, inserts, and deletes. Learn the five properties, rotations, and what interviews test.

An AVL tree is a self-balancing BST that guarantees O(log n) search, insert, and delete. Learn the balance factor, rotations, and interview patterns.

A binary search tree stores sorted data in a shape that searches itself. Here's the invariant, the operations, and the coding interview patterns that test it.
Learn what a balanced binary tree is, why it guarantees O(log n), and how to ace the balance-check interview problem in a single O(n) pass.

A full binary tree requires every node to have zero or two children. Learn the definition, leaf count proof, and where full trees appear in coding interviews.

A complete binary tree stores itself in a flat array. Learn the definition, how it differs from full and perfect trees, and why heaps depend on it.
A binary tree is a node with two child pointers. Learn the types, traversals, complexity, and recursive patterns behind every tree interview problem.

Learn how the heapify algorithm works: sift-down, build-heap in O(n), and why that bound holds. The proof interviewers actually ask about.
Max heap data structure: the two rules, array layout, O(1) peek, O(log n) insert and extract, O(n) build, Python negation, and three key interview patterns.

A min-heap is a complete binary tree where every parent ≤ its children. Learn insert, extract-min, heapify, and the four interview patterns that use one.

What is a heap? A binary tree stored as a flat array, giving O(1) access to the min or max. The data structure behind every priority queue.

Learn how the priority queue data structure works, what operations cost O(log n), and the three patterns that show up most in coding interviews.

The deque data structure gives you O(1) push and pop at both ends. Learn how it works, how it's built, and when to use it in coding interviews.

Learn what a queue data structure is: FIFO ordering, O(1) operations, circular buffer implementation, and the BFS patterns that depend on it.

A stack is a LIFO data structure behind undo history, the call stack, and coding interview patterns like valid parentheses and monotonic stack problems.

A circular linked list has no null terminator. The last node loops back to the head. Learn how it works, when to implement it, and key interview patterns.