B-treePresented by : Carlos Andrés González Castro San Buenaventura University – Cali Systems Engineering 1105675
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.
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.
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.
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 nodes elements ordered. O If a leaf node is full, A single median is chosen from among the leafs 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ón O The separation value is inserted in the nodes parent, which may cause it to be split.
Deletion O 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 values in a leaf node, simply delete it from the node
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.
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.
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
Building a B-Tree O Now you want to insert the numbers 5, 15 and 23.
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.