Skip to content
Embercode
✕
Range queries and tricksQuick quiz

Mo, sqrt and search tricks

7 questions. Covers Persistent structures, binary search and ternary search.

Questions 1 to 5 of 7

  1. 1. Mo's algorithm uses the default block size B = n / sqrt(q). For n = 200000 positions and q = 200000 queries, what whole-number block size does the lesson's formula give, using integer division of the result?

    Type a number.

  2. 2. An AI says Mo's algorithm runs in O(n + q) time, because each query only adds or removes a few values. What is wrong with that claim?
  3. 3. Which statements about Mo's algorithm are true?

    Pick every answer that is true.

  4. 4. An AI proposes sqrt decomposition for range sums with point updates, with n = q = 200000. A Fenwick tree also handles this. Which choice is better, and why?
  5. 5. A persistent segment tree over the compressed values 0 to 3 (so m = 4 leaves) is built with three inserts, for the array [2, 0, 2]. Each insert copies the path from the root to one leaf, and that path has 3 nodes. How many new nodes are created in total?

    Type a number.

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.