Data Structures & AlgorithmsHardICPC regional · range queries

Problem: Which statement about the sparse table data structure for static range-minimum queries is correct?

  1. A. It answers queries in O(log n) with O(n) preprocessing and no overlap allowed
  2. B. It supports point updates in O(1)
  3. C. It needs O(n^2) preprocessing and O(log n) query time
  4. D. It answers each query in O(1) after O(n log n) preprocessing, because min is idempotent and two overlapping blocks cover the range

Correct answer: D. It answers each query in O(1) after O(n log n) preprocessing, because min is idempotent and two overlapping blocks cover the range

The overlap of two power-of-two blocks is harmless for min (idempotent), which allows an O(1) query. Point updates are not supported efficiently by a static sparse table.

More Coding Interview Problems questions

Exams that ask this topic