CS FundamentalsHardGATE CS (PYQ pattern)
A table is stored sorted on key K in 5000 pages (100 records each). Searching for one key with binary search over pages costs ceil(log2 5000) page reads. With a sparse primary index (one entry per data page, 200 entries per index page), what is the number of page reads for a single-key search using binary search on the index plus the data page?
- A. 6
- B. 13
- C. 7
- D. 5
Correct answer: A. 6
Index entries = 5000, index pages = 25; binary search on 25 pages: ceil(log2 25) = 5 reads, plus 1 data page = 6. Binary search directly on the data would need ceil(log2 5000) = 13.
More DBMS and SQL questions
- A secondary dense index on a non-key attribute of a file with 1,000,000 records uses 4096-byte pages, 12-byte key + 8-byte pointer entries…
- A table of 1,000,000 rows (100 rows per page, 10,000 pages) is clustered on A, with a B+ tree whose leaves hold 200 entries each; reaching…
- Sort-merge join of R (200 pages) and S (100 pages) with 15 buffer pages: each relation is fully sorted by external merge sort (pass 0…
- Under the deferred database modification scheme with a log, a crash occurs. The log holds <T1 start>, <T1,A,5>, <T1 commit>, <T2 start>…
- Under strict 2PL, T1 and T2 both hold S(A) and each now requests X(A) (a lock upgrade). T3 holds S(B) and requests X(A). T4 holds X(C) and…
- An ER diagram has a supertype PERSON(pid, name) with disjoint, total specialisation into STUDENT(gpa) and TEACHER(salary). Using the 'one…