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

Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applicationsJsaddam Hussain
 
B trees and_b__trees
B trees and_b__treesB trees and_b__trees
B trees and_b__treesmeghu123
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structureVardhil Patel
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search treeKrish_ver2
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary treeKrish_ver2
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptSeethaDinesh
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of treeRacksaviR
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Treekhabbab_h
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithmNeoClassical
 

What's hot (20)

Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
Binary tree
Binary tree Binary tree
Binary tree
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
B trees and_b__trees
B trees and_b__treesB trees and_b__trees
B trees and_b__trees
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
 
Binary search
Binary searchBinary search
Binary search
 
Tree traversal techniques
Tree traversal techniquesTree traversal techniques
Tree traversal techniques
 
Tree Traversal
Tree TraversalTree Traversal
Tree Traversal
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of tree
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
Linked list
Linked listLinked list
Linked list
 
Balanced Tree (AVL Tree & Red-Black Tree)
Balanced Tree (AVL Tree & Red-Black Tree)Balanced Tree (AVL Tree & Red-Black Tree)
Balanced Tree (AVL Tree & Red-Black Tree)
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Binary tree
Binary treeBinary tree
Binary tree
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithm
 

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
 

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

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
 

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

Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxsomshekarkn64
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 

Recently uploaded (20)

Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptx
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 

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