3.4.9 · D1Trees

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

3,023 words14 min readBack to topic

This page assumes nothing. Before you read the parent note, make sure every symbol below feels obvious. We build them in the order the topic needs them.


1. What is a "key"?

Why the topic needs it: a search tree only ever compares keys. The whole game is "find the folder with tab = 57 in as few steps as possible."


2. A node, and a tree

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

Look at the figure. The red box is the root. Lines going down are edges. The boxes at the very bottom with no lines beneath them are leaves. The number of lines leaving a node is its number of children.

Why the topic needs it: a B-tree is a tree of nodes. Everything — height, splitting, balance — is described using these words.


3. , , and the branching factor

Before any formula, let us name three plain quantities we will use constantly.

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

Both red trees in the figure hold the same number of leaves. The left one is binary () and tall. The right one is fat () and short. The topic's magic is making trees as fat — and therefore as short — as possible.


4. The logarithm — the tool that measures "how tall"

Now that (total keys) and (branching factor) have names, we can ask the key question: how many levels does it take?

Why the topic needs it: a tree with fanout holding keys has height about . That is the whole payoff of B-trees — see Big-O Notation for why -height means fast.


5. The parent's tuning knob: (and its limits)

Some textbooks instead use , the order, meaning "maximum children". The two are just two names for the same knob, related by (a node's max children). We stick with because the parent does.

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

Look at the red node in the figure: it holds keys (recall from §3 that is the number of keys inside one node), so it has children.

Why the topic needs it: every property in the parent ("at least keys", "at most ", height ) is written in these letters.


6. Sorted separators = the Binary-Search-Tree idea, generalised

Why the topic needs it: this is the "BST property generalised" the parent mentions. It is how you navigate a fat node. In a B+ tree these internal separators are only signposts — the real record still lives in a leaf.


7. Disk, block, seek — where the slowness comes from

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

The figure shows the speed gap as bar lengths (a log scale — each step is ). RAM is a sliver; an HDD seek is a giant red bar. This gap is the enemy the whole topic fights.


8. Balanced height & "all leaves at exactly the same depth"

Why the topic needs it: property 6 in the parent ("all leaves at the same depth") is precisely what lets the §4 leaf-count — and therefore the height bound — be exact rather than approximate.


Prerequisite map

The figure below shows how the plain ideas feed into the topic. Read it top to bottom: the plain ideas (keys, nodes) feed into fanout; the disk facts force one-node-per-block, which is the fanout; logs turn fanout into a short height; and balance makes that height a guarantee. All arrows meet at the parent topic.


Equipment checklist

Cover the right side and answer aloud. If any stumps you, re-read that section.

  • A key is ::: the value you search by; the record is the data attached to it.
  • (lowercase) denotes ::: the number of keys inside a single node.
  • The branching factor / fanout of a node is ::: how many children it actually has.
  • means ::: the exponent you raise to, to get (how many levels of fanout reach ).
  • Why does a bigger base shrink the log? ::: because each level multiplies size by more, so fewer levels reach .
  • In the height proof, do we use the minimum or maximum children per node, and why? ::: the minimum (), because the tallest possible tree happens when nodes are as empty as the rules allow.
  • Where does the in come from? ::: the from moving the across, the from the root having only 2 children.
  • If , the true height is at most ::: (round the upper bound down).
  • (minimum degree) controls ::: the minimum () and maximum () keys per non-root node.
  • How many keys may the root hold at minimum? ::: just 1 (or 0 if the tree is empty) — the root is exempt from the rule.
  • A node with keys has how many children, and why? ::: fences make gaps.
  • A block is ::: the smallest chunk of data a disk reads in one I/O (e.g. 4–16 KB).
  • Why is a seek the enemy? ::: it is ~10 ms on an HDD, ~ slower than a RAM access; we minimise their count.
  • Why do we make one node = one block? ::: a read gives a whole block free, so packing it with keys maximises fanout per read.
  • "All leaves at exactly the same depth" is needed because ::: it makes the §4 bottom-level leaf count exact, so the height bound is exact.
  • How does a B+ tree differ from a B-tree? ::: records live only in the leaves (internal nodes are signposts), and leaves are chained in a list for fast range scans.