Overview
A Sparse Table stores answers for intervals of length 1, 2, 4, and so on, enabling O(1) idempotent queries such as range minimum.
Precomputes overlapping power-of-two ranges for fast static range queries.
Compact metadata for implementation and discovery.
A Sparse Table stores answers for intervals of length 1, 2, 4, and so on, enabling O(1) idempotent queries such as range minimum.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n log n)
Average
O(1) query after preprocessing
Worst
O(n log n)
Space
O(n log n)
table[k][i] = op(table[k-1][i], table[k-1][i + 2^(k-1)])Builds an answer for a larger interval from two half-size intervals.
Show array intervals covered by overlapping power-of-two blocks.
Sparse Tables are for static data; updates require rebuilding, while disjoint sparse tables are a specialized static range-query variant.
What each reference supports for this entry.
Data-structures reference for sparse-table preprocessing, range-query lookup, and idempotent aggregate operations.
Good next jumps from the relationship graph, ranked for useful discovery.
Sparse tables answer static range queries, while segment trees support dynamic updates.