CS FundamentalsHardGATE CS (PYQ pattern)
A 10,000-page file is sorted by external merge sort with 21 buffer pages: later passes merge 20 runs at a time, and every pass reads and writes every page. Pass 0 either sorts 21 pages at a time (runs of 21 pages) or uses replacement selection, which produces runs averaging 2 x 21 = 42 pages. How many page I/Os does replacement selection save?
- A. 0
- B. 40,000
- C. 20,000
- D. 10,000
Correct answer: C. 20,000
Plain: ceil(10000/21) = 477 runs -> 24 -> 2 -> 1, so 1 + 3 = 4 passes = 80,000 I/Os. Replacement selection: ceil(10000/42) = 239 runs -> 12 -> 1, so 1 + 2 = 3 passes = 60,000 I/Os. Saving one full pass = 2 x 10,000 = 20,000. Longer runs help only when they cut the number of merge passes, which here they do.
More DBMS and SQL questions
- Block nested-loop join of R (800 pages) and S (300 pages) with 52 buffer pages (1 for the inner input, 1 for output, 50 for the outer…
- R(A, B) has 10,000 tuples with V(R, B) = 200; S(B, C) has 5,000 tuples with V(S, B) = 500 and V(S, C) = 100; T(C, D) has 2,000 tuples with…
- An extendible hash index uses the LOW-order bits of the hash value, with bucket capacity 2 and an initial directory of global depth 1 (two…
- A file of 100,000 records of 120 bytes is stored in 4096-byte blocks, each with an 8-byte header (records do not span blocks), sorted on…
- R(A, B, C, D, E) has the functional dependencies DB → A, A → C, D → C, C → B. R is decomposed and one fragment is R1(A, C, D). Counting…
- R(A, B, C, D, E) has FDs A → B, BC → D, D → E, E → B. Which of the following are implied? I. AC → D II. A → E III. AC → E IV. D → B V. CD…