Continued from my last question "Range Minimum Query approach (from tree to restricted RMQ)" (It's recommended to give it a read)
Again, from this tutorial on TopCoder, I have a few questions here and there, and I hope someone can clear them out.
So I transform a RMQ (Range Minimum Query) problem to a LCA (Lowest Common Ancestor) problem, and then transform it back, I can have an array that's simplified. (both transform can be found in the tutorial, and the simplified array is array L discussed in "From LCA to RMQ")
Anyway, I can get that array by using Euler Tour, and that's the core part of all the calculation.
First, I need to make it even simpler by making the whole array consists of only 1 and -1, so this is what I do: Ls[i] = L[i] - L[i-1]
.
The second step is actually partition, and that's simple enough, but there's this third step that confuses me.
Let A'[i] be the minimum value for the i-th block in A and B[i] be the position of this minimum value in A.
A refers to the L array in this sentence, so the minimum value would always be 1 or -1, and there's gonna be multiple 1s and -1s. It confuses me since I don't think this makes calculation easier.
The fourth step,
Now, we preprocess A' using the ST algorithm described in Section1. This will take O(N/l * log(N/l)) = O(N) time and space.
If A' only keep records of 1s and -1s, it would seemed useless to do anything on it.
The last step,
To index table P, preprocess the type of each block in A and store it in array T[1, N/l]. The block type is a binary number obtained by replacing -1 with 0 and +1 with 1.
What does it mean? To calculate each kind of combination? Like, 000
- 001
-.....?
It looks like multiple questions, but I was hoping that someone can just walk me thorough these last steps. Thanks!