CS FundamentalsVery hardProduct company interview · GATE level
A file has 200,000 fixed-length records of 200 bytes stored unspanned in 1024-byte blocks. A secondary index is built on a non-ordering key field: each index entry is a 12-byte key plus an 8-byte pointer, and the index is made multilevel until the top level fits in one block. How many index levels are there, and how many block accesses does it take to fetch a record by this key?
- A. 4 levels; 5 block accesses
- B. 3 levels; 4 block accesses
- C. 4 levels; 4 block accesses
- D. 1 level; 13 block accesses
Correct answer: A. 4 levels; 5 block accesses
A secondary index on a non-ordering field must be dense: one entry per record, 200,000 entries. Each block holds floor(1024/20) = 51 entries. Level 1: ceil(200,000/51) = 3,922 blocks. Level 2: ceil(3,922/51) = 77 blocks. Level 3: ceil(77/51) = 2 blocks. Level 4: 1 block. A search reads one block per level and then the data block: 4 + 1 = 5 accesses. The 3-level answer builds a sparse index with one entry per data block (40,000 entries), which is possible only on the ordering field. Binary search on level 1 alone would cost ceil(log2 3,922) + 1 = 13 accesses.
More DBMS and SQL questions
- Relations R (1000 blocks) and S (200 blocks) are joined with a block nested-loop join using M = 52 buffer blocks: M - 2 blocks hold a…
- Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). How many rows…
- Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4…
- Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4…
- Consider the schedule W2(A), R1(A), R2(A), W3(A), R3(A), R1(C). Which statement is correct?
- TS(T1) = 25, TS(T2) = 5, TS(T3) = 30; all read/write timestamps start at 0. Under basic timestamp ordering (no Thomas write rule), which…