Data Structures & AlgorithmsVery hardCodeforces Div2 E · offline queries
Problem: Which result is the basis of Mo's algorithm's complexity analysis?
- A. Each query runs in O(1)
- B. All queries are sorted by value only
- C. Pointer movements over sorted blocks total O((n + q) sqrt n)
- D. Moves cost O(n^2) total
Correct answer: C. Pointer movements over sorted blocks total O((n + q) sqrt n)
Sorting queries by block makes the right pointer move monotonically inside each block, giving the sqrt bound.
More Coding Interview Problems questions
- Problem: What is the expected number of comparisons of randomised quicksort on n distinct elements?
- Problem: Which property does the 'exchange argument' prove for an optimal greedy algorithm?
- Problem: Which structure supports both insertion and 'k-th smallest' queries in O(log n) each?
- Problem: What is the complexity of the Edmonds-Karp algorithm in terms of V and E?
- Problem: Which theorem counts the spanning trees of a graph as a determinant of a reduced Laplacian matrix?
- Problem: An undirected graph has edges 0-1, 0-2, 1-3, 2-3, 3-4, 4-5, 2-5 (7 edges, 6 vertices 0–5). How many distinct shortest paths (by…