SlideShare a Scribd company logo
1 of 11
Multi-ways Trees
SHEETAL WAGHMARE
M.TECH (Computer Science & Data Processing)
IIT KHARAGPUR
EMAIL-ID: shitu2iitkgp@gmail.com
sheetalw3@gmail.com
Multi way search tree
 A multiway search tree of order m is a search tree in which any node
can have at the most m children. The properties of a non-empty m way
search tree of order m are
1. Each node can hold maximum m-1 keys and can have maximum m
children.
2. A node with n children has n-1 key values i.e the number of key
values is one less than the number of children. Some of the children
can be NULL(empty subtree)
3. The keys in a node are in ascending order.
4. Keys in non-leaf node will divide the left and right subtrees where
values of left subtree keys will be less and value of right subtree keys
will be more than that particular key.
SHEETALWAGHMARE FROM IIT KHARAGPUR
Example
C1 K1 C2 K2 C3 K3 C4 K4 C5 K5 C6 K6 C7 K7 C8
1. This node has the capacity to hold 7 keys and 8 children.
2. K1 < K2 < K3 < K4 < K5 < K6 < K7
3. The key K1 is greater then all the keys in subtree pointed to by C1 and
less than all the keys in subtree pointed to by pointer C2. Similarly this
relation holds true for other keys also.
4. Keys(C1) < K1< Keys(C2) < K2 < Keys(C3) < K3 < Keys(C4)< K4 ….
Consider a node of m-way search tree of order 8
SHEETALWAGHMARE FROM IIT KHARAGPUR
Note:
From the definition of m-way search trees, we can say
that m-way search trees are generalized form of Binary
Search Trees and a Binary search tree can be considered as
an m-way search tree of order 2.
SHEETALWAGHMARE FROM IIT KHARAGPUR
B-Tree
 A B-tree of order m can be defined as an m-way search tree which is either
empty or satisfies the following properties:-
1. All leaf nodes are at the same level.
2. All non-leaf nodes (except root node) should have atleast m/2 children.
3. All nodes (except root node) should have atleast [(m/2) – 1] keys.
4. If the root node is a leaf node, then it will have atleast one key. If the
root node is a non-leaf node, then it will have atleast 2 children and
atleast one key.
5. A non-leaf node with n-1 keys values should have n non NULL children.
B-Tree is also known as Height Balanced m-way search tree
SHEETALWAGHMARE FROM IIT KHARAGPUR
Example
 B-tree of order 5
30 70
76 888 25 40 50
11 19 27 29 32 37 43 49 77 85 89 9756 67
71 73 75
1 3 5 7
SHEETALWAGHMARE FROM IIT KHARAGPUR
Searching in B-tree
30 70
76 888 25 40 50
11 19 27 29 32 37 43 49 77 85 89 9756 67
71 73 75
1 3 5 7
Suppose we want to search for 19. Searching will start from the root node
so first look at node [30 70] , the key is not there & since 19<30 , we move
to leftmost child of root which is [8 25]. The key is not present in this node
also 19 lies between 8 and 25 so we move to node [11 19] where we get the
desired key.
19<30
8<19<25
SHEETALWAGHMARE FROM IIT KHARAGPUR
Insertion in B-tree
 Create a B-tree of order 5
10,40,30,35,20,15,50,28,25,5,60,19,12,38,27,90,45,48
10 30 35 40 10 20 30 35 40
Node can contain only 4 values so
we will split the node
10 20
30
35 40
10 20
30
35 40
12 15 19 45 50 60 9025 27 285 38
SHEETALWAGHMARE FROM IIT KHARAGPUR
Now to insert 48
10 20
30
35 40
12 15 19 45 50 60 9025 27 285 38
10 20
30
35 40 50
12 15 19 45 5025 27 285 38
We cannot insert
48 in this node
bcz node can
contain at the
most 4 values
only. So we have
to split the node
45 48 50 60 90
60 90
Move
50 to
parent
node
SHEETALWAGHMARE FROM IIT KHARAGPUR
Animation for insertion
Insertion in Full Tree
Insertion when tree is not FULL
SHEETALWAGHMARE FROM IIT KHARAGPUR
SHEETAL WAGHMARE FROM IIT KHARAGPUR

More Related Content

What's hot

Quick sort algorithn
Quick sort algorithnQuick sort algorithn
Quick sort algorithnKumar
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]Muhammad Hammad Waseem
 
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxAlbin562191
 
UNIT III NON LINEAR DATA STRUCTURES – TREES
UNIT III 	NON LINEAR DATA STRUCTURES – TREESUNIT III 	NON LINEAR DATA STRUCTURES – TREES
UNIT III NON LINEAR DATA STRUCTURES – TREESKathirvel Ayyaswamy
 
Binary search tree
Binary search treeBinary search tree
Binary search treeKousalya M
 
trees in data structure
trees in data structure trees in data structure
trees in data structure shameen khan
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListPTCL
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary searchZia Ush Shamszaman
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort AlgorithmLemia Algmri
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESSowmya Jyothi
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Treekhabbab_h
 

What's hot (20)

Quick sort algorithn
Quick sort algorithnQuick sort algorithn
Quick sort algorithn
 
Binary tree
Binary treeBinary tree
Binary tree
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptx
 
UNIT III NON LINEAR DATA STRUCTURES – TREES
UNIT III 	NON LINEAR DATA STRUCTURES – TREESUNIT III 	NON LINEAR DATA STRUCTURES – TREES
UNIT III NON LINEAR DATA STRUCTURES – TREES
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked List
 
Splay Tree
Splay TreeSplay Tree
Splay Tree
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
 
Single linked list
Single linked listSingle linked list
Single linked list
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
1.7 avl tree
1.7 avl tree 1.7 avl tree
1.7 avl tree
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 

Similar to Multi-way Trees and B-Trees Explained

B TREE ( a to z concept ) in data structure or DBMS
B TREE ( a to z concept ) in data structure  or DBMSB TREE ( a to z concept ) in data structure  or DBMS
B TREE ( a to z concept ) in data structure or DBMSMathkeBhoot
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data StructureMeghaj Mallick
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search TreeINAM352782
 
Lecture 11 data structures and algorithms
Lecture 11 data structures and algorithmsLecture 11 data structures and algorithms
Lecture 11 data structures and algorithmsAakash deep Singhal
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)Trupti Agrawal
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search treeKrish_ver2
 

Similar to Multi-way Trees and B-Trees Explained (10)

B+ tree.pptx
B+ tree.pptxB+ tree.pptx
B+ tree.pptx
 
B TREE ( a to z concept ) in data structure or DBMS
B TREE ( a to z concept ) in data structure  or DBMSB TREE ( a to z concept ) in data structure  or DBMS
B TREE ( a to z concept ) in data structure or DBMS
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
DAA PPT.pptx
DAA PPT.pptxDAA PPT.pptx
DAA PPT.pptx
 
Lecture 11 data structures and algorithms
Lecture 11 data structures and algorithmsLecture 11 data structures and algorithms
Lecture 11 data structures and algorithms
 
2-4 tree
2-4 tree2-4 tree
2-4 tree
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
 
4.2 bst 03
4.2 bst 034.2 bst 03
4.2 bst 03
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 

More from SHEETAL WAGHMARE (7)

Heaps
HeapsHeaps
Heaps
 
Sales Force Automation
Sales Force AutomationSales Force Automation
Sales Force Automation
 
Enterprise Relationship Management
Enterprise Relationship ManagementEnterprise Relationship Management
Enterprise Relationship Management
 
Call Center
Call CenterCall Center
Call Center
 
Introduction To CRM
Introduction To CRMIntroduction To CRM
Introduction To CRM
 
Tree
TreeTree
Tree
 
Linklist
LinklistLinklist
Linklist
 

Recently uploaded

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 

Recently uploaded (20)

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 

Multi-way Trees and B-Trees Explained

  • 1. Multi-ways Trees SHEETAL WAGHMARE M.TECH (Computer Science & Data Processing) IIT KHARAGPUR EMAIL-ID: shitu2iitkgp@gmail.com sheetalw3@gmail.com
  • 2. Multi way search tree  A multiway search tree of order m is a search tree in which any node can have at the most m children. The properties of a non-empty m way search tree of order m are 1. Each node can hold maximum m-1 keys and can have maximum m children. 2. A node with n children has n-1 key values i.e the number of key values is one less than the number of children. Some of the children can be NULL(empty subtree) 3. The keys in a node are in ascending order. 4. Keys in non-leaf node will divide the left and right subtrees where values of left subtree keys will be less and value of right subtree keys will be more than that particular key. SHEETALWAGHMARE FROM IIT KHARAGPUR
  • 3. Example C1 K1 C2 K2 C3 K3 C4 K4 C5 K5 C6 K6 C7 K7 C8 1. This node has the capacity to hold 7 keys and 8 children. 2. K1 < K2 < K3 < K4 < K5 < K6 < K7 3. The key K1 is greater then all the keys in subtree pointed to by C1 and less than all the keys in subtree pointed to by pointer C2. Similarly this relation holds true for other keys also. 4. Keys(C1) < K1< Keys(C2) < K2 < Keys(C3) < K3 < Keys(C4)< K4 …. Consider a node of m-way search tree of order 8 SHEETALWAGHMARE FROM IIT KHARAGPUR
  • 4. Note: From the definition of m-way search trees, we can say that m-way search trees are generalized form of Binary Search Trees and a Binary search tree can be considered as an m-way search tree of order 2. SHEETALWAGHMARE FROM IIT KHARAGPUR
  • 5. B-Tree  A B-tree of order m can be defined as an m-way search tree which is either empty or satisfies the following properties:- 1. All leaf nodes are at the same level. 2. All non-leaf nodes (except root node) should have atleast m/2 children. 3. All nodes (except root node) should have atleast [(m/2) – 1] keys. 4. If the root node is a leaf node, then it will have atleast one key. If the root node is a non-leaf node, then it will have atleast 2 children and atleast one key. 5. A non-leaf node with n-1 keys values should have n non NULL children. B-Tree is also known as Height Balanced m-way search tree SHEETALWAGHMARE FROM IIT KHARAGPUR
  • 6. Example  B-tree of order 5 30 70 76 888 25 40 50 11 19 27 29 32 37 43 49 77 85 89 9756 67 71 73 75 1 3 5 7 SHEETALWAGHMARE FROM IIT KHARAGPUR
  • 7. Searching in B-tree 30 70 76 888 25 40 50 11 19 27 29 32 37 43 49 77 85 89 9756 67 71 73 75 1 3 5 7 Suppose we want to search for 19. Searching will start from the root node so first look at node [30 70] , the key is not there & since 19<30 , we move to leftmost child of root which is [8 25]. The key is not present in this node also 19 lies between 8 and 25 so we move to node [11 19] where we get the desired key. 19<30 8<19<25 SHEETALWAGHMARE FROM IIT KHARAGPUR
  • 8. Insertion in B-tree  Create a B-tree of order 5 10,40,30,35,20,15,50,28,25,5,60,19,12,38,27,90,45,48 10 30 35 40 10 20 30 35 40 Node can contain only 4 values so we will split the node 10 20 30 35 40 10 20 30 35 40 12 15 19 45 50 60 9025 27 285 38 SHEETALWAGHMARE FROM IIT KHARAGPUR
  • 9. Now to insert 48 10 20 30 35 40 12 15 19 45 50 60 9025 27 285 38 10 20 30 35 40 50 12 15 19 45 5025 27 285 38 We cannot insert 48 in this node bcz node can contain at the most 4 values only. So we have to split the node 45 48 50 60 90 60 90 Move 50 to parent node SHEETALWAGHMARE FROM IIT KHARAGPUR
  • 10. Animation for insertion Insertion in Full Tree Insertion when tree is not FULL SHEETALWAGHMARE FROM IIT KHARAGPUR
  • 11. SHEETAL WAGHMARE FROM IIT KHARAGPUR