Download presentation
Presentation is loading. Please wait.
1
CS 257, Spring’08 Presented By: Presented By: Farzana Forhad Farzana Forhad ID : 107
2
Agenda Agenda The features and different functionalities of B- Tree in terms of index structureThe features and different functionalities of B- Tree in terms of index structure The Structure of B-TreesThe Structure of B-Trees Applications of B-TreesApplications of B-Trees Lookup in B-TreesLookup in B-Trees Range QueriesRange Queries Insertion into B-TreesInsertion into B-Trees Deletion from a B-TreeDeletion from a B-Tree
3
B-Tree B-Tree B-Trees automatically maintain as many levels of index as is appropriate for the size of the file being indexed.B-Trees automatically maintain as many levels of index as is appropriate for the size of the file being indexed. B-Trees manage the space on the blocks they use so that every block is between half used and completely full. No overflow blocks are needed.B-Trees manage the space on the blocks they use so that every block is between half used and completely full. No overflow blocks are needed.
4
Structure of B-Trees There are three layers in binary trees- the root, an intermediate layer and leavesThere are three layers in binary trees- the root, an intermediate layer and leaves In a B-Tree each block have space for n search-key values and n+1 pointersIn a B-Tree each block have space for n search-key values and n+1 pointers [next slide explains the structure of a B-Tree]
5
Structure of a B-Tree 13 317 2923191713117532 43 41374743 23
6
Applications of B-Trees Applications of B-Trees The search key of the B-tree is the primary key for the data file. That is, there is one key-pointer pair in a leaf for every record of the data file.The search key of the B-tree is the primary key for the data file. That is, there is one key-pointer pair in a leaf for every record of the data file. The data file is sorted by its primary key and the B-tree is a index with one key-pointer pair at a leaf for each block of the data file.The data file is sorted by its primary key and the B-tree is a index with one key-pointer pair at a leaf for each block of the data file. The data file is sorted by a attribute that is not a key and this attribute is the search key for the B- tree. For each key value K that appears in the data file there is one key-pointer pair at a leaf. That pointer goes to the first of the records that have K as their sort-key value.The data file is sorted by a attribute that is not a key and this attribute is the search key for the B- tree. For each key value K that appears in the data file there is one key-pointer pair at a leaf. That pointer goes to the first of the records that have K as their sort-key value. [next slide explains the B-Tree application] [next slide explains the B-Tree application]
7
Applications of a B-Tree 17 377 23 1713 7532 43 41374743 - 23
8
Lookup in B-Trees Lookup in B-Trees Suppose we want to find a record with search key 40. We will start at the root, the root is 13, so the record will go the right of the tree. Then keep searching with the same concept.
9
Looking for block “40” Looking for block “40” 13 317 2923191713117532 43 41374743 23
10
Range Queries Range Queries B-trees are used for queries in which a range of values are asked for. Like, SELECT * SELECT * FROM R FROM R WHERE R. k >= 10 AND R. k = 10 AND R. k <= 25;
11
Insertion into B-Trees Insertion into B-Trees
12
Insertion into B-Trees (cont..) Insertion into B-Trees (cont..)
15
Deletion form a B-Tree
16
Deletion form a B-Tree (cont..)
19
More (B+ Trees) More (B+ Trees)
20
Q? Q?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.