Eroxl's Notes
B-Tree

A b-tree is a type of self-balancing tree which maintains sorted data. The b-tree can be thought of as a generalization of binary search trees allowing each node to store multiple keys rather than just one. The structure of a B-tree ensures that all leaf nodes are at the same depth.

B-tree's allow for key's per node which then can have up to children. The subtree then stores keys between the key and . The subtree stores all values less than the key and the subtree stores all values greater than the key.

B-Tree node's must always have one less key than they have children, additionally, all non-root nodes must have between and children, the root in comparison must have between and children ensuring it has at least 1 key.

B-tree's are especially efficient compared to binary search tree's for large datasets where data may need to be stored and retrieved from secondary storage instead of memory, this property is important and commonly utilized for creating efficient databases.

Insertion

Insertion into a B-tree follows a specific sequence of operations to maintain the balance and properties of the tree. The key idea is to always insert into a leaf node while ensuring that no node ever exceeds keys.

Firstly the b-tree is searched for the first leaf node that can contain the key (even if it already has the maximum amount of keys). Next the key is inserted into the node.if the node was already full the node is split.

All the keys less then the median are in placed in one of the new child node and all keys greater are placed in the other. The median is moved up into the parent node and if the parent then overflows as well the process is repeated again for the parent node.