+ All Categories
Home > Education > Nikhat b+ trees ppt

Nikhat b+ trees ppt

Date post: 13-Apr-2017
Category:
Upload: nikihat-maniyar
View: 124 times
Download: 14 times
Share this document with a friend
24
A Dynamic Index structure B + TREES:
Transcript
Page 1: Nikhat b+ trees ppt

A Dynamic Index structure

B + TREES:

Page 2: Nikhat b+ trees ppt

SUB-TOPICS What is a B+ Tree? Format of a Node Search Insert Delete Duplicates

Page 3: Nikhat b+ trees ppt

What is a B+ Tree? The B+ tree search structure is a balanced tree

in which the internal nodes direct the search and the leaf nodes contain the data entries.

OR

A B+ tree is a balanced tree in which every path from the root of the tree to a leaf is of the same length, and each non leaf node of the tree has between [n/2] and [n] children, where n is fixed for a particular tree.

Page 4: Nikhat b+ trees ppt

What is a B+ Tree? Structure of a B+ Tree

Page 5: Nikhat b+ trees ppt

What is a B+ Tree?

It contains index pages and data pages. The capacity of a leaf has to be 50% or more. For example: if n = 4, then the key for each node is between 2 to 4. The index page will be 4 + 1 = 5.

Example of a B+ tree with four keys (n = 4) looks like this:

Page 6: Nikhat b+ trees ppt

What is a B+ Tree?

Page 7: Nikhat b+ trees ppt

FORMAT OF A NODE The format of a node is

the same as for ISAM as shown below:

Page 8: Nikhat b+ trees ppt

FORMAT OF A NODE Non-leaf nodes with m index entries

contain m + 1 pointers to children. Pointer Pi points to a sub tree in which all key values K are such that Ki ≤ K<Ki+1.

As special cases, Po points to a tree in which all key values are less than K1, and Pm points to a tree in which all key values are greater than or equal to Km. For leaf nodes, entries are denoted as k∗, as usual.

Page 9: Nikhat b+ trees ppt

SEARCH The Searching time in a B+ tree is much

shorter than most of other kinds of trees. For example: To search a data in one million

key-values, a balanced binary requires about 20 block reads, in contrast only 4 block reads is required in B+ Tree.

Page 10: Nikhat b+ trees ppt

SEARCH Since no structure change in

a B+ tree during a searching process, so just compare the key value with the data in the tree, then give the result back.

For example: find the value 15, and 45 in below tree.

Page 11: Nikhat b+ trees ppt

SEARCHResult: 1. For the value of 45, not found. 2. For the value of 15, return the position

where the pointer located

Page 12: Nikhat b+ trees ppt

INSERTSince insert a value into a B+ tree may cause

the tree unbalance, so rearrange the tree if needed.

Example #1: Insert 28 into the below tree.

Page 13: Nikhat b+ trees ppt

INSERTResult:

Page 14: Nikhat b+ trees ppt

INSERTExample #2: insert 70 into below tree

Page 15: Nikhat b+ trees ppt

INSERTProcess: split the

tree

50 55 60 65 70

50 55 60 65 70

Violate the 50%

rule, split the leaf

Page 16: Nikhat b+ trees ppt

INSERTResult: chose the middle key 60, and place it

in the index page between 50 and 75.

Page 17: Nikhat b+ trees ppt

DELETESame as insertion, the tree has to be rebuild if the deletion result violate the rule of B+ tree.

Example #1: delete 70 from the tree

60 65 This is

OK.

Page 18: Nikhat b+ trees ppt

DELETEResult:

Page 19: Nikhat b+ trees ppt

DELETEExample #2: delete 25 from below tree, but 25

appears in the index page.

28 30

But…

This is OK.

Page 20: Nikhat b+ trees ppt

DELETEResult: replace 28 in the index page.

Add 28

Page 21: Nikhat b+ trees ppt

DELETEExample #3: delete 60 from the below tree

65

50 55 65 Violet

the 50% rule

Page 22: Nikhat b+ trees ppt

DELETEResult: delete 60 from the index page and

combine the rest of index pages.

Page 23: Nikhat b+ trees ppt

DUPLICATES The search, insertion, and deletion algorithms ignore

the issue of duplicate keys, that is, several data entries with the same key value.

how duplicates can be handled? We handle them just like any other entries and several

leaf pages may contain entries with a given key value. To retrieve all data entries with a given key value, we

must search for the left-most data entry with the given key value and then possibly retrieve more than one leaf page (using the leaf sequence pointers).

Page 24: Nikhat b+ trees ppt

Recommended