Question

Consider a database implemented using B+ tree for file indexing and installed on a disk drive with block size of 4 KB. The size of search key is 12 bytes and the size of tree/disk pointer is 8 bytes. Assume that the database has one million records. Also assume that no node of the B+ tree and no records are present initially in main memory. Consider that each record fits into one disk block. The minimum number of disk accesses required to retrieve any record in the database is _______.

Official answer and solution
Official answer
4
From
Official GATE 2020 answer key

Solution

Compute the fanout capacity of B+ tree nodes and determine tree height plus data block access.

Parameters:

  • Block size B=4 KB=4096 bytesB = 4\text{ KB} = 4096\text{ bytes}
  • Search key size K=12 bytesK = 12\text{ bytes}
  • Pointer size P=8 bytesP = 8\text{ bytes}
  • Number of records N=1,000,000=106N = 1,000,000 = 10^6

Capacities of B+ tree nodes:

  • Internal node: holds pp pointers and p−1p - 1 keys:
    p⋅P+(p−1)⋅K≤B  ⟹  8p+12(p−1)≤4096  ⟹  20p≤4108  ⟹  p≤205p \cdot P + (p - 1) \cdot K \le B \implies 8p + 12(p - 1) \le 4096 \implies 20p \le 4108 \implies p \le 205
  • Leaf node: holds kk key-pointer pairs and 1 block pointer to the next leaf:
    k(K+P)+P≤B  ⟹  20k+8≤4096  ⟹  20k≤4088  ⟹  k≤204k(K + P) + P \le B \implies 20k + 8 \le 4096 \implies 20k \le 4088 \implies k \le 204

Minimum height of B+ tree to index 10610^6 records:

  • To minimize height (and disk accesses), consider maximum fanout:
    • Level 1 (Root): 1 node, up to 205 pointers.
    • Level 2 (Internal): up to 205 nodes, up to 205×205=42,025205 \times 205 = 42,025 pointers.
    • Level 3 (Leaf nodes): 42,025 leaf nodes can hold up to 42,025×204≈8.57×10642,025 \times 204 \approx 8.57 \times 10^6 records, easily accommodating 10610^6 records.
  • Thus, the minimum tree height is 3 levels.

Total disk accesses:

  • 1 access for root node (Level 1)
  • 1 access for internal node (Level 2)
  • 1 access for leaf node (Level 3)
  • 1 access for the data block containing the actual record
  • Total minimum disk accesses = 3+1=43 + 1 = 4.
Final answer

4

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2020 Computer Science and Information Technology (CS)
Question
64 of 65, printed as CS Q.54
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.