SlideShare a Scribd company logo
1 of 16
Multiway Trees
M-Way Tree
• An M-way tree is a search tree in which each
node can have from 0 to m subtrees where
m=order of the tree
• Given a nonempty multiway tree, the following
properties:
– Each node has 0 to m subtrees
– Given a nod with k<m subtrees, the node contains k
subtree pointers, some of which may be null and
k-1 data entries
• The key values in the first subtree are all less
than the key in the first entry.
M-Way search trees
• An M-way tree is a search tree in which each node can have
from 0 to m subtrees, where m= B-tree order.
• Properties of M-way tree:
– Each node has 0 to m subtrees
– The key values in the first subtree < key value in the first
entry; key values in the other subtrees >= key value in their
parent entry.
– Keys of the data entries are ordered
key1<= key2 <=……key n
– All subtrees are themselves multiway trees
– Diagram
– Example
• Advantages
– The height of the tree is greatly reduced.
• Disadvantages
– it is not balanced.
Difference between binary tree and
multiway tree
• Each node in a binary tree has one entry
• Each node in a multiway tree have multiple
entries.
B-trees
• B-tree is an m-way search tree with the
following additional properties:
– The root is either a leaf or it has 2…m subtrees
– All internal nodes have atleast m/2 non-null
subtrees(i.e minimum) and at most m non-null
subtrees
– A leaf node has atleast m/2 -1 non-null
subtrees(i.e minimum) and at most m-1 non-null
subtrees
Table containing number of subtrees and no of entries for a
given order
Order Number of subtrees Number of entries
Minimum(m/2) Maximum(m) Minimum(m/2)-1 Maximum(m-1)
3 2 3 1 2
4 2 4 1 3
5 3 5 2 4
6 3 6 2 5
• The maximum number of total nodes in a B-
tree of order m and maximum height h
Total nodes=(mh+1 -1)/(m-1)
• The maximum number of total keys in a B-
tree of order m and maximum height h
Total nodes=mh+1 -1
Inserting a value in a B-Tree
• Suppose a value k is inserted in a B-Tree. After
searching for a appropriate leaf node to insert
the value k, the values present at that particular
leaf node is counted. This leads to 2 possibilities
– The leaf node is not full
– The leaf node is full
• The leaf node is not full :
– The value is inserted at its appropriate position in
the node and the insertion procdure ends
Inserting a value in a B-Tree
• The leaf node is full
• If the leaf node is full, that node is split into two nodes
Deleting a value in a node
• Suppose a value k is deleted from a B-Tree. After
searching for a appropriate leaf node to delete the
value k, the values present at that particular leaf
node is counted. This leads to 2 possibilities
– The number of values>= minimum number
of values required
– The number of values< minimum number
of values required
• The number of values>= minimum number of
values required
on deleting this value , the number of values that are
left in the node satisfy the condition of B-Tree.
• The number of values< minimum number of
values required
There are two possibilities
• The left or right sibling of the node from which the value is
deleted contains more than the required minimum number
of values
– In that case , the value of its parent is moved to
the node and a value from its sibling(left or right
which contains more number of value s than the
required minimum values) is moved to its parent.
• The left or right sibling of the node from which the value is
deleted contains exactly the required minimum number of
values
– The value of its parent is moved to the node and the node
is merged with its sibling. If the parent also contains the
minimum number of values then the same procedure of
merging the node with its sibling is applied.
Difference between B-Tree and B+Tree
B Tree
• In B tree we can store both
keys and data in the
internal/leaf nodes.
• A B tree, on the other hand,
would require a traversal of
every level in the tree.
B+Tree
• In B+ tree only the data is
stored in the leaf nodes.
• The leaf nodes of B+ trees
are linked, so doing a full
scan of all objects in a tree
requires just one linear pass
through all the leaf nodes.
• Used in popular file systems
such as NTFS, JFS, XFS. Also
using to index tables in
database systems such as
MYSQL
B* Trees
• The root has at least 2 and at most 2*floor[(2*m-2)/3] +1
children. Eg: for an tree of order 9 the root is full when it
contains 11 children and 10 data elements.
• Non-root nodes have at most m and at least ceiling[(2*m-1)/3]
children. Eg: for a tree of order 9 , a non-root node is full when
there are 9 children and each non-root node must have 6
children and 5 data elements
• All paths from the root to a leaf are the same length i.e all
leaves are on the same level.

More Related Content

Similar to Multiway Trees.ppt

B tree ,B plus and graph
B tree ,B plus and graph B tree ,B plus and graph
B tree ,B plus and graph RaaviKapoor
 
Unit-5 Advanced tree zxcppt
Unit-5 Advanced tree                     zxcpptUnit-5 Advanced tree                     zxcppt
Unit-5 Advanced tree zxcpptDhruvilSTATUS
 
chapter 6.1.pptx
chapter 6.1.pptxchapter 6.1.pptx
chapter 6.1.pptxTekle12
 
tree-160731205832.pptx
tree-160731205832.pptxtree-160731205832.pptx
tree-160731205832.pptxMouDhara1
 
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10sumitbardhan
 
Data structure(Part 2)
Data structure(Part 2)Data structure(Part 2)
Data structure(Part 2)SURBHI SAROHA
 
109885098-B-Trees-And-B-Trees in data structure.ppt
109885098-B-Trees-And-B-Trees in data structure.ppt109885098-B-Trees-And-B-Trees in data structure.ppt
109885098-B-Trees-And-B-Trees in data structure.pptssuser19bb13
 
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptxTREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptxasimshahzad8611
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
Search tree,Tree and binary tree and heap tree
Search tree,Tree  and binary tree and heap treeSearch tree,Tree  and binary tree and heap tree
Search tree,Tree and binary tree and heap treezia eagle
 

Similar to Multiway Trees.ppt (20)

Tree chapter
Tree chapterTree chapter
Tree chapter
 
B tree ,B plus and graph
B tree ,B plus and graph B tree ,B plus and graph
B tree ,B plus and graph
 
Unit-5 Advanced tree zxcppt
Unit-5 Advanced tree                     zxcpptUnit-5 Advanced tree                     zxcppt
Unit-5 Advanced tree zxcppt
 
chapter 6.1.pptx
chapter 6.1.pptxchapter 6.1.pptx
chapter 6.1.pptx
 
B trees dbms
B trees dbmsB trees dbms
B trees dbms
 
tree-160731205832.pptx
tree-160731205832.pptxtree-160731205832.pptx
tree-160731205832.pptx
 
Module - 5_Trees.pdf
Module - 5_Trees.pdfModule - 5_Trees.pdf
Module - 5_Trees.pdf
 
B+ trees and height balance tree
B+ trees and height balance treeB+ trees and height balance tree
B+ trees and height balance tree
 
Binary tree
Binary treeBinary tree
Binary tree
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
Tree
TreeTree
Tree
 
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10
 
Data structure(Part 2)
Data structure(Part 2)Data structure(Part 2)
Data structure(Part 2)
 
109885098-B-Trees-And-B-Trees in data structure.ppt
109885098-B-Trees-And-B-Trees in data structure.ppt109885098-B-Trees-And-B-Trees in data structure.ppt
109885098-B-Trees-And-B-Trees in data structure.ppt
 
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptxTREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
 
Tree
TreeTree
Tree
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Data Structures 4
Data Structures 4Data Structures 4
Data Structures 4
 
Tree
TreeTree
Tree
 
Search tree,Tree and binary tree and heap tree
Search tree,Tree  and binary tree and heap treeSearch tree,Tree  and binary tree and heap tree
Search tree,Tree and binary tree and heap tree
 

Recently uploaded

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 

Recently uploaded (20)

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 

Multiway Trees.ppt

  • 2. M-Way Tree • An M-way tree is a search tree in which each node can have from 0 to m subtrees where m=order of the tree • Given a nonempty multiway tree, the following properties: – Each node has 0 to m subtrees – Given a nod with k<m subtrees, the node contains k subtree pointers, some of which may be null and k-1 data entries • The key values in the first subtree are all less than the key in the first entry.
  • 3. M-Way search trees • An M-way tree is a search tree in which each node can have from 0 to m subtrees, where m= B-tree order. • Properties of M-way tree: – Each node has 0 to m subtrees – The key values in the first subtree < key value in the first entry; key values in the other subtrees >= key value in their parent entry. – Keys of the data entries are ordered key1<= key2 <=……key n – All subtrees are themselves multiway trees – Diagram – Example
  • 4. • Advantages – The height of the tree is greatly reduced. • Disadvantages – it is not balanced.
  • 5. Difference between binary tree and multiway tree • Each node in a binary tree has one entry • Each node in a multiway tree have multiple entries.
  • 6. B-trees • B-tree is an m-way search tree with the following additional properties: – The root is either a leaf or it has 2…m subtrees – All internal nodes have atleast m/2 non-null subtrees(i.e minimum) and at most m non-null subtrees – A leaf node has atleast m/2 -1 non-null subtrees(i.e minimum) and at most m-1 non-null subtrees
  • 7. Table containing number of subtrees and no of entries for a given order Order Number of subtrees Number of entries Minimum(m/2) Maximum(m) Minimum(m/2)-1 Maximum(m-1) 3 2 3 1 2 4 2 4 1 3 5 3 5 2 4 6 3 6 2 5
  • 8. • The maximum number of total nodes in a B- tree of order m and maximum height h Total nodes=(mh+1 -1)/(m-1) • The maximum number of total keys in a B- tree of order m and maximum height h Total nodes=mh+1 -1
  • 9. Inserting a value in a B-Tree • Suppose a value k is inserted in a B-Tree. After searching for a appropriate leaf node to insert the value k, the values present at that particular leaf node is counted. This leads to 2 possibilities – The leaf node is not full – The leaf node is full • The leaf node is not full : – The value is inserted at its appropriate position in the node and the insertion procdure ends
  • 10. Inserting a value in a B-Tree • The leaf node is full • If the leaf node is full, that node is split into two nodes
  • 11. Deleting a value in a node • Suppose a value k is deleted from a B-Tree. After searching for a appropriate leaf node to delete the value k, the values present at that particular leaf node is counted. This leads to 2 possibilities – The number of values>= minimum number of values required – The number of values< minimum number of values required
  • 12. • The number of values>= minimum number of values required on deleting this value , the number of values that are left in the node satisfy the condition of B-Tree. • The number of values< minimum number of values required There are two possibilities
  • 13. • The left or right sibling of the node from which the value is deleted contains more than the required minimum number of values – In that case , the value of its parent is moved to the node and a value from its sibling(left or right which contains more number of value s than the required minimum values) is moved to its parent.
  • 14. • The left or right sibling of the node from which the value is deleted contains exactly the required minimum number of values – The value of its parent is moved to the node and the node is merged with its sibling. If the parent also contains the minimum number of values then the same procedure of merging the node with its sibling is applied.
  • 15. Difference between B-Tree and B+Tree B Tree • In B tree we can store both keys and data in the internal/leaf nodes. • A B tree, on the other hand, would require a traversal of every level in the tree. B+Tree • In B+ tree only the data is stored in the leaf nodes. • The leaf nodes of B+ trees are linked, so doing a full scan of all objects in a tree requires just one linear pass through all the leaf nodes. • Used in popular file systems such as NTFS, JFS, XFS. Also using to index tables in database systems such as MYSQL
  • 16. B* Trees • The root has at least 2 and at most 2*floor[(2*m-2)/3] +1 children. Eg: for an tree of order 9 the root is full when it contains 11 children and 10 data elements. • Non-root nodes have at most m and at least ceiling[(2*m-1)/3] children. Eg: for a tree of order 9 , a non-root node is full when there are 9 children and each non-root node must have 6 children and 5 data elements • All paths from the root to a leaf are the same length i.e all leaves are on the same level.