Overlap is safe for a minimum
transcript
A sparse table answers minimums instantly. It uses two overlapping blocks. Why is the overlap safe? The data must never change.
Level zero holds the values themselves. Level one holds minimums of two values. Level two holds minimums of four values. Each level is built from the level below.
Take the minimum of hours two to four. Take the block that starts at hour two. Take the block that ends at hour four. They overlap at hour three. The smaller is six. Two reads give the answer, whatever the length.
The minimum of a value with itself is that value. A sum would count hour three twice. Overlapping sums give eighteen, not fifteen. So the overlap cannot hurt a minimum.
Use it for minimums and maximums. Use it only when values never change. Sums need prefix sums or a Fenwick tree instead.
A tree of blocks fixes both. Full breakdown in the lecture.