A **B-tree** is a data structure that consists of ordered nodes arranged in a balanced tree. Each node contains *keys* (the numbers that you see) and *children* (the nodes directly below it).

Nodes are sorted to the left, middle, or right depending on whether their keys are less than, in between, or greater than the parent's keys. Add some values to the demo for a visual demonstration of this.

The *root* is the top node, *internal* nodes are in the middle, and *leaf* nodes are on the bottom. Using this terminology, a valid B-tree of order *m* obeys the following rules:

- Every node has at most
*m*children. - Every internal node has at least
*ciel( m / 2 )*children. - The root node has at least 2 children if it's not a leaf.
- A non-leaf node with
*k*children contains*k-1*keys. - All leaves are on the same level.

B-trees allow you to quickly search for values, and they're often used in databases and file systems.