0 · Recall Warm-up
Answer from memory first. Answers are in the Answer Vault at the bottom.
- What is the maximum number of keys in a B-tree of order p and height h? from Lesson 5.5.3
- In a B-tree, can a search stop at an internal node? from Lesson 5.5.2
- What is a sparse index? from Lesson 5.3.1
1 · The Hook
"All students with roll between 1,200 and 1,450." In a B-tree, the keys in that range are scattered over internal nodes and leaves: you must walk up and down the tree. A B+ tree keeps every key in the leaves, in order, and links the leaves left to right. A range query becomes: one descent, then a walk along the leaf chain. That is why real database systems use B+ trees.
2 · Predict First
In a B+ tree, the key 40 appears in an internal node. Must it also appear in a leaf?
Make a guess in your head. The answer opens Section 3.
3 · Core Concept
Predict First — the answer
Yes. In a B+ tree, internal nodes only guide the search; every key (with its record pointer) is stored in a leaf. Internal keys are copies used as separators.
Structure (order p for internal nodes, p_leaf for leaves)
Internal nodes
- Up to p child pointers and p − 1 keys; no record pointers.
- Non-root internal nodes have at least ⌈p/2⌉ children; the root at least 2 (unless it is the only node).
- Keys are separators: for a separator k, keys ≥ k go right (a common convention).
Leaf nodes
- Up to p_leaf entries ⟨key, record pointer⟩, sorted, plus one next-leaf pointer.
- Non-root leaves hold at least ⌈p_leaf/2⌉ entries.
- All leaves are on the same level and together contain every key in sorted order.
Search
Every search goes from the root down to a leaf (internal nodes never hold the record pointer). Cost = height (levels) + 1 block for the data record, unless the leaf stores the records themselves.
Range queries
- Search for the low end of the range: reach the first leaf that may contain it.
- Read entries and follow next-leaf pointers until a key exceeds the high end.
Cost = height + (number of extra leaves read) (+ data blocks).
B+ tree as a multilevel index
The leaf level is a dense index (one entry per record, sorted), and the internal levels form a sparse multilevel index over the leaves: exactly Lesson 5.3.3, made dynamic and balanced.
4 · Visual
A B+ tree (max 2 keys per node). Internal keys 30, 50, 70 are copies; every key appears in a leaf, and the leaves are chained left to right (dashed arrows) for range scans.
5 · Worked Examples
Example 1 Easy
In the tree above, which nodes are visited to find 60? To list all keys from 25 to 65?
Solution
60: [50] → [70] → leaf [50 60]: 3 nodes. Range 25–65: descend [50] → [30] → leaf [10 20] (25 < 30), skip 10 and 20, then follow the chain: [30 40], [50 60], and [70] (70 > 65 stops). 4 leaves read; output 30, 40, 50, 60.
Example 2 Medium
Why does a B+ tree usually have a smaller height than a B-tree on the same block size?
Solution
Internal B+ nodes hold no record pointers, so more keys and child pointers fit per block: higher fan-out → fewer levels.
Example 3 GATE
A B+ tree has 3 levels; each leaf holds about 60 entries. A range query matches 600 records whose keys are consecutive. About how many index block accesses are needed (excluding data blocks)?
Solution
3 to reach the first leaf, then about 600/60 = 10 leaves in all, so about 2 + 10 = 12 (the first leaf counted once). The exact count depends on where the range starts inside the first leaf.
6 · GATE Traps
- B+ internal nodes have no record pointers; leaves have ⟨key, record pointer⟩ entries and one next pointer.
- Every key is in a leaf; internal keys may be stale copies after deletions and still guide correctly.
- Every search reaches a leaf (cost = height), unlike a B-tree.
- The leaf chain is what makes range queries cheap.
7 · Memory Hook
"Signposts above, shop shelves below, and the shelves are connected."
8 · Connect the Dots
Chapter 5.5 built B-trees; this lesson moved all data to linked leaves. Next: computing the two orders of a B+ tree (internal and leaf) from block, key and pointer sizes, GATE's most common B+ tree question.
9 · Self-Test
GATE format. Try every question before opening the vault.
Q1 · MCQ · 1 mark(s) — Structure
In a B+ tree, record pointers are stored in:
- (A) both internal and leaf nodes
- (B) internal nodes only
- (C) the root only
- (D) leaf nodes only
Q2 · MCQ · 1 mark(s) — Search
In a B+ tree of height 4, a successful search for a key reads how many tree nodes?
- (A) at most 3
- (B) exactly 4
- (C) exactly 1
- (D) between 1 and 4
Q3 · MSQ · 2 mark(s) — Properties
Which are true of B+ trees?
- (A) Internal node keys may also appear in leaves.
- (B) A key can appear only once in the whole tree.
- (C) Leaves are linked for sequential access.
- (D) Every key appears in some leaf.
Q4 · NAT · 2 mark(s) — Range
In the 3-level example tree (leaves [10 20], [30 40], [50 60], [70]), how many leaves are read to answer "keys from 15 to 55"?
Numerical answer: ________
Q5 · MCQ · 1 mark(s) — Why
B+ trees are preferred for range queries because:
- (A) they use hashing
- (B) they have no root
- (C) their internal nodes store records
- (D) their leaves are sorted and chained
10 · Rule Card
- Internal: ≤ p children, ≤ p − 1 keys, no record pointers; non-root ≥ ⌈p/2⌉ children.
- Leaves: ≤ p_leaf ⟨key, Pr⟩ entries + next pointer; non-root ≥ ⌈p_leaf/2⌉ entries; all keys here, sorted.
- Search always reaches a leaf (cost = height).
- Range: descend to the low key, then follow leaf links.
- Leaf level = dense index; internal levels = sparse multilevel index.
11 · Concept Ledger
Unlocked in this lesson. From here on, these terms may be used.
B+ treeinternal (index) nodeleaf nodeseparator keynext-leaf pointerleaf chainrange query in B+ treep and p_leaf
12 · Answer Vault
Reveal answers when you’re ready
Recall Warm-up
- p^h − 1.
- Yes; every key appears once, possibly in an internal node.
- One entry per block (anchor); needs sorted data.
Self-Test
Q1 Answer: (D) · 1 mark(s)
Internal nodes route; leaves hold the data pointers.
- (A) is wrong: That is a B-tree.
- (B) is wrong: Reversed.
- (C) is wrong: No.
Re-read: Lesson 5.6.1 — B+ tree: internal vs leaf nodes, leaf chaining, range queries
Q2 Answer: (B) · 1 mark(s)
Every search ends at a leaf.
- (A) is wrong: No.
- (C) is wrong: No.
- (D) is wrong: That is a B-tree.
Re-read: Lesson 5.6.1 — B+ tree: internal vs leaf nodes, leaf chaining, range queries
Q3 Answer: (A) (C) (D) · 2 mark(s)
Internal keys are copies.
- (B) is wrong: That is the B-tree rule.
Re-read: Lesson 5.6.1 — B+ tree: internal vs leaf nodes, leaf chaining, range queries
Q4 Answer: 3 · 2 mark(s)
Leaves [10 20], [30 40], [50 60]; 60 > 55 stops the scan.
Re-read: Lesson 5.6.1 — B+ tree: internal vs leaf nodes, leaf chaining, range queries
Q5 Answer: (D) · 1 mark(s)
One descent, then a chain walk.
- (A) is wrong: No.
- (B) is wrong: No.
- (C) is wrong: No.
Re-read: Lesson 5.6.1 — B+ tree: internal vs leaf nodes, leaf chaining, range queries