Data Structures & AlgorithmsHardICPC regional · range queries
Problem: Which statement about the sparse table data structure for static range-minimum queries is correct?
- A. It answers queries in O(log n) with O(n) preprocessing and no overlap allowed
- B. It supports point updates in O(1)
- C. It needs O(n^2) preprocessing and O(log n) query time
- 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
- Problem: Which statement about heavy-light decomposition for path queries on a tree is correct?
- Problem: Which statement about Fermat's little theorem is correct?
- Problem: What is the time for one point update and one rectangle-sum query in a 2D Fenwick tree on an n x n grid?
- Problem: Why can subtree queries on a rooted tree be answered with a range query on an array?
- Problem: An undirected graph has 10 vertices (0–9) and 6 edges: 0-1, 1-2, 3-4, 5-6, 6-7, 7-5. What is the minimum number of new edges that…
- Problem: In a graph with vertices 0–7 and edges 0-1, 1-2, 2-3, 3-0, 3-4, 4-5, 5-6, 6-4, 6-7, which edges lie on at least one cycle? How…