|
Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Builds the sparse table for computing min/max/gcd/lcm/...etc for any contiguous sub-segment of the array.This is an example of computing the index of the minimum value.
log2(i+1)pow(2,i), and we can reuse the computation that we did for the range of length pow(2,i-1).So, ST[j][i] = min( ST[j-1][i], ST[j-1][i + pow(2,j-1)]). [2][3] = min(ST[1][3], ST[1][5])