GATE Computer ScienceHardGATE CS

A sparse table for range-minimum queries on an array of 1000 elements stores, for each level k = 0, 1, ..., ⌊log₂ 1000⌋, one entry for every start position i such that the block [i, i + 2ᵏ − 1] fits inside the array. How many entries does it store in total?

  1. A. 10000
  2. B. 9000
  3. C. 8987
  4. D. 8977

Correct answer: C. 8987

There are 10 levels (k = 0 to 9). Level k has 1000 − 2ᵏ + 1 entries, so the total is 10 × 1001 − (1 + 2 + ... + 512) = 10010 − 1023 = 8987.

More Programming and Data Structures (GATE) questions

Exams that ask this topic