DBMS Notes
A B-Tree (Balanced Tree) is a self-balancing, sorted tree data structure that maintains sorted data and allows searches, insertions, and deletions in O(log...
What is a B-Tree?
A B-Tree (Balanced Tree) is a self-balancing, sorted tree data structure that maintains sorted data and allows searches, insertions, and deletions in O(log n) time. It is designed for efficient disk-based storage where reading a full node (disk block) at a time is optimal.
Proposed by Rudolf Bayer and Edward McCreight in 1970.
B-Tree Node Structure
Example — B-Tree of Order 3
Search in B-Tree
| 2. If K = Kᵢ | FOUND, return associated data |
| 3. If K < Kᵢ | recurse into child Pᵢ₋₁ |
| 4. If K > all keys | recurse into rightmost child |
| 5. If N is a leaf and K not found | NOT FOUND |
| Example | Search for 50 in tree above |
| Step 1: Root [30|70] | 50 > 30, 50 < 70 → go to middle child [40|60] |
| Step 2: [40|60] | 50 > 40, 50 < 60 → go to middle child [50] |
| Step 3: [50] | found! ✓ |
| Cost | 3 node reads = 3 disk I/Os |
Insertion in B-Tree
| 2. If leaf has space (< m−1 keys) | insert K there |
| Example | Insert 45 into order-3 B-Tree |
| Find position | goes into node [40|60] |
| [40|60] is full | split! |
| Median = 50 | promote 50 to parent |
| Left | [40], Right: [60] |
Deletion in B-Tree
B-Tree Height and Performance
| Minimum height | h_min = ⌈log_m(n+1)⌉ |
| Maximum height | h_max = ⌊log_⌈m/2⌉((n+1)/2)⌋ + 1 |
| Operations | O(log_m(n)) = O(log n / log m) |
B-Tree vs B+ Tree Preview
| Feature | B-Tree | B+ Tree |
|---|---|---|
| Data storage | All nodes (internal + leaf) | Only leaf nodes |
| Internal nodes | Keys + data pointers | Keys only (routing) |
| Leaf nodes | Linked? No | Linked as list ✓ |
| Range queries | Less efficient | Very efficient |
| Space usage per node | Less keys (data takes space) | More keys (routing only) |
| Most used in DBMS | No | Yes (almost universally) |
The key limitation of B-Trees is that data stored in internal nodes reduces the fan-out (number of children per node), making the tree taller. B+ Trees solve this.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for B-Tree.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Database Management Systems (DBMS) topic.
Search Terms
dbms, database management systems (dbms), unit, tree, b-tree
Related Database Management Systems (DBMS) Topics