1. B-tree
Presented by : Carlos Andrés González
Castro
San Buenaventura University – Cali
Systems Engineering
1105675
2. B-tree
O B-tree is a balanced multiway search tree.
O Emerged from the need to do a quick
search of any content, without
reorganizing the file.
3. Rules
O Each tree node must have a minimum of n
values at all times, except the root.
O The maximum number of values that a
node can have is 2 * n.
O The tree is always balanced.
O All leaf nodes belong together on the last
level.
4. Search
O Searching is similar to searching a binary
search tree. Starting at the root, the tree is
recursively traversed from top to bottom
O If the key is not in the root and a leaf is
reached, the key does not exist.
5. Insertion
O All insertions start at a leaf node.
O If the node contains fewer than the maximum
legal number of elements, Insert the new
element in the node, keeping the node's
elements ordered.
O If a leaf node is full, A single median is chosen
from among the leaf's elements and the
Values less than the median are put in the
new left node and values greater than the
median are put in the new right node, with the
median acting as a separation value.
6. Inserción
O The separation value is inserted in the
node's parent, which may cause it to be
split.
7. Deletion
O Locate and delete the item, then
restructure the tree to regain.
8. Types of deletion
O Deletion from a leaf node: Search for the
value to delete, If the value's in a leaf
node, simply delete it from the node
9. Types of deletion
O Deletion from an internal node: If the
value is in an internal node, choose a new
separator (either the largest element in
the left subtree or the smallest element in
the right subtree), remove it from the leaf
node it is in, and replace the element to
be deleted with the new separator.
10. Building a B-Tree
O We wants to show how a B-tree grows in
order 2 (n = 2).
O The tree starts empty and we are going to
enter 4 numbers (10,20,30,40).
O First creates the root node and then add
the 4 numbers.
11. Building a B-Tree
O Now you want to insert the number 25.
O Two child nodes are created and the
median number goes to the root and the
numbers less than the median pass to the
node left child and the numbers older than
the median to the right child node
12. Building a B-Tree
O Now you want to insert the numbers
5, 15 and 23.
13. Formando un Árbol B
O As the root will have m = 2 values, it can
not continue to having two son, now must
have (m + 1) = 3 children.