CS FundamentalsVery hardProduct company interview · GATE level
A B+ tree holds 10,000 keys in its leaves. A leaf holds at most 20 and at least 10 keys; an internal node has at most 30 and at least 15 children; the root, when it is not a leaf, has at least 2 children. What are the minimum and the maximum possible number of levels (counting the root level and the leaf level)?
- A. Minimum 3, maximum 5
- B. Minimum 3, maximum 3
- C. Minimum 4, maximum 4
- D. Minimum 3, maximum 4
Correct answer: D. Minimum 3, maximum 4
Fewest levels: pack every node. 10,000/20 = 500 leaves, 500/30 → 17 internal nodes, and one root over those 17: 3 levels (two levels could hold only 30 x 20 = 600 keys). Most levels: fill every node as little as allowed. A tree with h levels needs at least 2 x 15^(h-2) x 10 keys: h = 4 needs 2 x 225 x 10 = 4,500, which 10,000 keys can supply (for example 1,000 leaves, 66 nodes, 4 nodes, root), but h = 5 needs 67,500. So between 3 and 4 levels.
More DBMS and SQL questions
- 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…
- 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?