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?

  1. A. p = 205, n = 186
  2. B. p = 204, n = 186
  3. C. p = 205, n = 185
  4. 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

Exams that ask this topic