b-tree

14
B-tree Presented by : Carlos Andrés González Castro San Buenaventura University – Cali Systems Engineering 1105675

Upload: carlos-andres-gonzalez

Post on 13-Dec-2014

967 views

Category:

Education


0 download

DESCRIPTION

http://www.slideshare.net/CarlosAndresGonzalez/exposicion-arbol-b

TRANSCRIPT

Page 1: B-Tree

B-tree

Presented by : Carlos Andrés González Castro

San Buenaventura University – CaliSystems Engineering

1105675

Page 2: B-Tree

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.

Page 3: B-Tree

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.

Page 4: B-Tree

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.

Page 5: B-Tree

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.

Page 6: B-Tree

InserciónO The separation value is inserted in

the node's parent, which may cause it to be split.

Page 7: B-Tree

DeletionO Locate and delete the item, then

restructure the tree to regain.

Page 8: B-Tree

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

Page 9: B-Tree

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.

Page 10: B-Tree

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.

Page 11: B-Tree

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

Page 12: B-Tree

Building a B-TreeONow you want to insert the

numbers 5, 15 and 23.

Page 13: B-Tree

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.

Page 14: B-Tree

Thanks