# Algorithms_in_C++: ST

Loading...
Searching...
No Matches
ST

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.

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.

Returns
  void @complexity: O(n.log(n))< precomputing `log2(i+1)`

Note
  notice how we deal with the range of length `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])