CS FundamentalsVery hardProduct company interview · GATE level
A B+ tree uses 4096-byte blocks, 12-byte search keys, 8-byte block pointers and 10-byte record pointers. An internal node with p child pointers stores p - 1 keys; a leaf stores n (key, record pointer) pairs plus one block pointer to the next leaf. What are the largest possible p and n?
- A. p = 205, n = 186
- B. p = 204, n = 186
- C. p = 205, n = 185
- D. p = 341, n = 185
Correct answer: C. p = 205, n = 185
Internal node: 8p + 12(p - 1) ≤ 4096 gives 20p ≤ 4108, so p = 205 (205 pointers and 204 keys use 4088 bytes). Leaf: 22n + 8 ≤ 4096 gives n ≤ 185.8, so n = 185 (4078 bytes); 186 pairs would need 4100 bytes once the next-leaf pointer is included. Forgetting that pointer gives n = 186, forgetting the '- 1' on the keys gives p = 204, and p = 341 counts only the 12-byte keys.
More DBMS and SQL questions
- 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…
- 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…