Sparse table
Sparse table
Introduction
Sparse Table is a data structure for processing range queries on a static array (the array does not change).
Most often used for:
- RMQ (Range Minimum Query)
- Range Maximum
- GCD on a segment
- other idempotent operations
After preprocessing:
- build:
- query:
Main idea
Any number can be represented as a sum of powers of two:
