Embercode
✕
Segment TreesQuick quiz

Sparse table and GCD

8 questions. Covers Range GCD in Python and why it is not invertible.

Questions 1 to 5 of 8

  1. 1. What does this program print, one number per line? ``python def gcd(a, b): while b != 0: a, b = b, a % b return a print(gcd(48, 36)) print(gcd(12, -18)) print(-7 % 3) print(7 % -3) ``
  2. 2. What does this program print, one value per line? ``python a = [3, 9, 4, 4, 0] level1 = [min(a[i], a[i + 1]) for i in range(len(a) - 1)] print(level1) print((7).bit_length() - 1) print((8).bit_length() - 1) ``
  3. 3. Which statements about the sparse table in this lesson are true? Pick all that apply.

    Pick every answer that is true.

  4. 4. A sparse table is used to answer range sums with the same overlapping-blocks query it uses for minimum. True or false, with the reason?
  5. 5. For an array of 100000 numbers, how many levels does a sparse table have, counting level 0 up to the top level?

5 question(s) left on this page.