Sparse Table Visualizer
Build a sparse table for static range minimum or maximum queries, then inspect the two power-of-two blocks used for an O(1) answer.
Sparse table input
Range query
Step controls
Step 1 of 5: Start minimum query [2, 7] with length 6.
Sparse table levels
Start minimum query [2, 7] with length 6.
Array view
Query summary
Trace
What is a Sparse Table Visualizer?
A sparse table visualizer shows how static range minimum or maximum queries can be answered using precomputed power-of-two blocks.
This tool builds each table level from an input array. For a query [left, right], it chooses k = floor(log2(length)), reads the block starting at left, reads the block ending at right, and combines those two values.
For the full cluster of related pages, browse the Data Structure Visualizers hub.
How to use this sparse table visualizer
- Paste an array of whole numbers.
- Choose minimum or maximum mode.
- Choose the left and right indexes for a static range query.
- Run the query to highlight the two power-of-two blocks.
- Compare each table level with the ranges it precomputes.
Sparse table complexity
Sparse tables build in O(n log n) time and use O(n log n) space. After preprocessing, range minimum and range maximum queries run in O(1) time because the answer is formed from two overlapping blocks.
Use the Segment Tree Visualizer or Fenwick Tree Visualizer when values need to change after preprocessing.