B Treeb+ Tree
B Treeb+ Tree
TOPICS TO BE COVERED
• INTRODUCTION
• CONSTRUCTING A B-TREE
• INSERTING IN A B-TREE
Introduction to B tree
B tree is used to index the data and provides fast access to
the actual data stored on the disks since, the access to value
stored in a large database that is stored on a disk is a very
time consuming process.
One of the main reason of using B tree is its capability to
store large number of keys in a single node and large key
values by keeping the height of tree relatively small.
Suppose m=5.
•Number of keys in internal node is 1 less than its number of children.
•All internal node except the root have at least Г5/2˥ = 3 children (or at least 2 keys)
•A leaf node contains not more than 4 keys.
•Leaf node must contain at least Г5/2˥ - 1 = 2 keys.
Construct a B-tree of order 5. That means each node can have upto 5 childrens.
Practice???
B tree of order 3:
The elements to be inserted are 4, 2, 20, 10, 1, 14, 7, 11, 3, 8.
B Tree of order 4:
5, 3, 21, 9, 1, 13, 2, 7, 10, 12, 4, 8
B+ Trees
• In B Tree, Keys and records both can be stored in the internal as well
as leaf nodes. Whereas, in B+ tree, records (data) can only be stored
on the leaf nodes while internal nodes can only store the key values.
• The leaf nodes of a B+ tree are linked together in the form of a singly
linked lists to make the search queries more efficient.
• B+ Tree are used to store the large amount of data which can not be
stored in the main memory. Due to the fact that, size of main
memory is always limited, the internal nodes (keys to access
records) of the B+ tree are stored in the main memory whereas, leaf
nodes are stored in the secondary memory.
References
1. Li`pschutz, Seymour, “Data Structures”, Schaum's Outline Series,
Tata McGraw Hill.
2. Data structure and algorithm by Narasimha Karumanchi.
3. www.tutorialspoint.com
4. www.geeksforgeeks.com
Books Recommended
• Goodrich, Michael T., Tamassia, Roberto, and Mount, David M.,
“Data Structures and Algorithms in C++”, Wiley Student Edition.
• Aho, Alfred V., Ullman, Jeffrey D., Hopcroft ,John E. “Data
Structures and Algorithms”, Addison Wesley
• Lipschutz, Seymour, “Data Structures”, Schaum's Outline Series,
Tata McGraw Hill.
• Gilberg/Forouzan,” Data Structure with C ,Cengage Learning.
• Augenstein,Moshe J , Tanenbaum, Aaron M, “Data Structures
using C and C++”, Prentice Hall of India