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?
- A. 10000
- B. 9000
- C. 8987
- 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.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A segment tree over positions 0 to 12 (13 elements) is built recursively: the root is node 1, the node for [lo, hi] splits at mid = (lo +…
- A B-tree with minimum degree t = 3 (every node except the root has between 2 and 5 keys) is built with the CLRS insertion procedure, which…
- Items 1, 2, 3, 4, 5 arrive in this order and are inserted, each at either the front or the back of a double-ended queue (the choice is…
- A tree has 16 nodes numbered 0 to 15 with the parent array parent[1..15] = 0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 9, 9, 10 (node i has parent…
- The same 16-node tree (parent array 0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 9, 9, 10 for nodes 1 to 15, root 0) is to be cut by deleting edges…
- A binary tree is given in preorder with # for an empty child: 1 2 4 8 # # 9 # # 5 # 10 # # 3 6 # 11 # # 7 12 # # 13 # #. What is the…