Hard Data Structures Advanced Structures
Why are B-trees used in databases instead of binary trees?
Answer
B-trees are optimized for disk-based storage where I/O is the bottleneck. They have large branching factor (hundreds of children per node) matching disk block size, minimizing tree height and disk reads. A B-tree with 1000-way branching and millions of keys has height 2-3 (only 2-3 disk reads). They maintain balance automatically, support range queries efficiently, and keep data sorted. B+ trees, a variant storing data only in leaves, are most common in databases.
IIT Certified
Master These Concepts with IIT Certification
175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.
Relevant for Roles
Database Developer Storage Systems Engineer Backend Architect