I was reading about static array queries and this is what I found:
Minimum Queries: There is an O(nlogn) time preprocessing method after which we can answer any minimum query in O(1) time.
The idea is to precalculate all values of min(a, b) where b - a + 1 (the length of the range) is a power of two. The number of precalculated values is O(nlogn), because there are O(logn) range lengths that are powers of two.
The values can be calculated efficiently using the recursive formula:
min(a,b) = min(min(a, a + w - 1), min(a + w, b))
where b-a+1 is a power of two and w = (b - a + 1) / 2
What is meant by the part quoted above? Why do we calculate the minimum only for certain lengths?
What is the idea and the intuition behind it? What does the logic do?
It's kind of a hunch that it must be related to something about a binary tree because we're considering just the powers of two for the lengths.