3.4.9 · D2Trees

Visual walkthrough — B-tree and B+ tree — motivation (disk storage), properties

2,146 words10 min readBack to topic

Before we touch a single symbol, let us agree on the picture and the words.


Step 0 — The vocabulary we will actually use

We will use exactly two rules from the parent definition, nothing more:

Why these and not the others? Because to prove the tree is short, we ask: "What is the tallest a tree could possibly get?" A tree gets tall when boxes are as empty as the rules allow — so we only care about the minimum amounts. That is why every rule above says "at least."


Step 1 — WHAT makes a tree tall: empty boxes

Figure — B-tree and B+ tree — motivation (disk storage), properties

WHAT: the left tree packs many keys per box (fat, height 1). The right tree obeys the minimum rules (skinny, height 2) for the same key count. WHY: the height bound is a promise about the worst case, so we build the worst case on purpose. PICTURE: the amber boxes on the right are only half-full — that is exactly Rule B being squeezed.


Step 2 — Count the boxes on each level

Figure — B-tree and B+ tree — motivation (disk storage), properties

WHAT: each cyan number counts the minimum boxes on that level. WHY: more boxes lower down means more room for keys — we need this count to add up the keys later. PICTURE: the branching fan widens by a factor of at every step; the amber arrows show one box spawning children.

Reading the picture level by level:

depth minimum number of boxes

Let us read the general term symbol by symbol:

  • the is the " children of the root" from Rule C — it seeds the multiplication;
  • the is the branching factor from Rule A — one factor of per level below level 1;
  • the exponent counts how many times we multiplied by to reach depth (we start multiplying only from depth 1, hence , not ).

Step 3 — Turn boxes into a key-count

Figure — B-tree and B+ tree — motivation (disk storage), properties

WHAT: each level's box-count gets multiplied by keys-per-box. WHY: this converts "how many boxes" into "how many keys," which is what actually measures. PICTURE: the amber tag on each box reads " keys" — the minimum load.

Adding the root's single key plus every level from depth down to the bottom depth :

Reading it piece by piece:

  • on the left is the real key count; the says the real tree holds at least this much, because we assumed everything is minimally filled;
  • the lone is the root contributing its single guaranteed key;
  • pulled out front is the keys-per-box factor, the same for every non-root box;
  • the sum adds the box-counts of levels , where is the depth of the bottom (leaf) level.

Step 4 — Collapse the sum (why a geometric series appears)

The geometric-series shortcut is:

  • the left side is (the exponent runs up to );
  • the right side is the shortcut: numerator , denominator — no adding required.

Plug it into Step 3 (the constant rides along outside the sum):

Now watch the cancellation:

  • the we multiplied by, and the in the denominator, are the same number, so they cancel;
  • what survives is .

WHAT: we compressed the whole tree's key count into the tidy . WHY: with a single we can now solve for using a logarithm. PICTURE: see below — the staircase of level-sums flattening into one bar.

Figure — B-tree and B+ tree — motivation (disk storage), properties

Step 5 — Solve for the height (why a logarithm, and which one)

Rearrange to isolate :

  • we added to both sides to clear the ;
  • we divided both sides by to leave alone.

Now apply to both sides — since is increasing, the direction is preserved:

  • is the tree's height (bottom depth) — the number of disk reads a lookup costs;
  • pulled down from the exponent, answering " to what power?";
  • the argument is the -side we isolated.

WHAT: the height is at most of (roughly) . WHY: because is huge (hundreds), this base makes the log tiny — the whole payoff. PICTURE: the final figure plots how flat this curve is.

Figure — B-tree and B+ tree — motivation (disk storage), properties

Step 6 — Edge and degenerate cases (never leave a gap)

Figure — B-tree and B+ tree — motivation (disk storage), properties

Case (empty tree). No boxes, height is undefined/; there is nothing to read. The bound is vacuous and does no harm — we simply never enter the tree.

Case (single key). One root box, height . Check the formula: . ✔ The bound gives exactly — no descent needed.

Case (smallest legal degree). Then keys max, key min per box. This is the tallest a B-tree ever gets (least branching). Even here , i.e. only one level worse than a perfect binary tree — still logarithmic. Larger only makes the tree shorter, never taller.

Why the root is exempt. If the root also needed keys, a tree with a single key () could not legally exist. The exemption is what lets tiny trees be valid — and it is exactly the lone "" term back in Step 3.


The one-picture summary

Figure — B-tree and B+ tree — motivation (disk storage), properties

This single blueprint chains every step: minimum boxes multiply by each level (Step 2) → each holds keys (Step 3) → the geometric sum collapses to (Step 4) → a base- log frees (Step 5) → giving a tree only ~ tall.

Recall Feynman: the whole walkthrough in plain words

We wanted to prove a B-tree is short. A tree gets tall only when its boxes are nearly empty, so we imagined the emptiest legal tree — every box at its minimum. Then we just counted. Level by level the number of boxes multiplies by (because each box must have at least children). Each box carries at least keys, so total keys is (boxes) × (keys-per-box), added over all levels. That sum is a geometric series — every term is the last times — so it has a neat shortcut, and after cancelling it becomes simply . Since must be at least that, we flipped it around: the exponent was trapped up high, and the tool that drags an exponent down is a logarithm base . Out popped . Because is in the hundreds, that log is tiny — four-ish for a billion keys — and four is the number of slow disk reads we pay. Every corner (empty, one key, smallest ) checks out. Done.

Recall Quick self-test

Why does the branching multiply by and not per level? ::: is the minimum number of children (Rule A); is the minimum number of keys (Rule B). Boxes multiply by children, so the factor is . Why base in the final log and not base ? ::: The trapped exponent sits on a base- power (), and is the exact inverse of " to a power." For , what does the bound give? ::: , matching a single root box of height .


See also: Binary Search Tree, AVL Tree, Red-Black Tree, Disk and Memory Hierarchy, Database Indexing, File Systems, Big-O Notation.