B-tree
Presented by : Carlos Andrés González Castro
San Buenaventura University – CaliSystems Engineering
1105675
B-treeO 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.
RulesO 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.
SearchO 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.
InsertionO 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.
InserciónO The separation value is inserted in
the node's parent, which may cause it to be split.
DeletionO Locate and delete the item, then
restructure the tree to regain.
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
Types of deletionO 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.
Building a B-TreeO 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.
Building a B-TreeO 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
Building a B-TreeONow you want to insert the
numbers 5, 15 and 23.
Formando un Árbol BO As the root will have m = 2 values , it
can not continue to having two son, now must have (m + 1) = 3 children.
Thanks