Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 1.72 KB

File metadata and controls

31 lines (25 loc) · 1.72 KB

B-Tree

Characteristics:

  1. Root may have 0 or 1 element to MAX, other nodes have at least MIN elements
  2. Space in one node: maximum = 2 * minimum
  3. Elements in a node are stored in a sorted array, from the smallest to the largest
  4. Number of subtrees = number of elements in parent + 1
  5. Every leaf has the same depth

Operations: Add a new node: ascend the middle node to its parent when reach maximum limit of a node
Remove from a B-Tree: replace with the smallest node from its right subtree or the largest node from its left subtree. Merge siblings and rotate if necessary, making sure each node has minimum number of elements

Number of values contained: maximum * (1 - (maximum + 1) ^ (height + 1)) / 1 - (maximum + 1) Example: a B tree with minimum of 10, height of two can store 9260 values

B+ Tree

When split a leaf, we copy the middle key up:
image
When split an internal node or root, we move the middle key up:
image
Because there’s no need to redundantly store the association for internal nodes.

Adding is the same as B tree except for the leaf node, where you need to leave a copy behind.

Removing from a B+ tree:
image -> remove 70 -> image -> remove 80 -> image