A **B-tree of order $m$** is a tree that satisfies the following properties:
* Every node has at most $m$ children.
* Every node, except for the root, has at least $m / 2$ children.
* All leaves appear on the same level.
* A node with $k$ children contains $k - 1$ keys sorted in monotonically increasing order.
The above is a modification of Knuth's definition in his "Art of Computer Programming" that defines leaves of the tree more consistently with how I use the term elsewhere. It also pulls in concepts from CLRS (such as keys needing to be sorted within nodes).
What is the search runtime of a B-tree of order $m$ and height $h$?
Back: $O(mh)$
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1723321489725-->
END%%
%%ANKI
Basic
*Why* does searching a B-tree of order $m$ and height $h$ take $O(mh)$ time?
Back: Each node may have $m - 1$ keys, and we may check $h$ nodes.
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1723321489726-->
END%%
%%ANKI
Basic
How many disk accesses are performed when searching a B-tree of order $m$ and height $h$?
Back: $O(h)$
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1723321489727-->
END%%
%%ANKI
Basic
*Why* does the number of disk accesses when searching a B-tree of height $h$ equal $O(h)$?
Back: The size of each node presumably corresponds to a block of memory.
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1723321489728-->
END%%
%%ANKI
Basic
What is the search runtime of a B-tree of order $m$ containing $n$ keys?
Back: $O(m\log_m{n})$
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1723321489729-->
END%%
%%ANKI
Basic
*Why* does searching a B-tree of order $m$ containing $n$ keys take $O(m\log_m{n})$ time?
Back: Each node may have $m - 1$ keys, and we may check $\log_m{n}$ nodes.
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1723321489730-->
END%%
%%ANKI
Basic
How many disk accesses are performed when searching a B-tree of order $m$ containing $n$ keys?
Back: $O(\log_m{n})$
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1723321489731-->
END%%
%%ANKI
Basic
*Why* does the number of disk accesses when searching a B-tree of order $m$ containing $n$ keys equal $O(\log_m{n})$?
Back: The size of each node presumably corresponds to a block of memory.
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1723321489732-->
END%%
## Insertions
A node of a B-tree of order $m$ is considered full when it has $m$ children (or equivalently $m - 1$ keys). Insertion operates analagously to a binary tree. If the node the key was inserted into then contains $m$ keys, split the node into two and place the median into the original parent node. This action may propagate upwards. If the root node becomes full, create a new root containing the median of the original root.
%%ANKI
Cloze
A node in a B-tree of order $m$ is considered full when it has {$m - 1$} keys.