SlideShare a Scribd company logo
M-WAY SEARCH TREE
Multiway Search Tree
 A binary search tree has one value in each node
and two subtrees.
 A multiway tree is a tree that can have more than
two children. A multiway tree of order m (or an m-
way tree) is one in which a tree can have m
children.
 M is the order of the tree.
multiway tree of order 5
Properties
 By definition an m-way search tree is a m-way tree
in which:
 Each node has m children and m-1 key fields
 The keys in each node are in ascending order.
 The key of the data entries are ordered as
key1<=key2<=<=key3………………..<keyk
 All subtree are them seleves multiway trees.
 The keys in the first i children are smaller than the i th key
 The keys in the last m-i children are larger than the i th
key
Example
 Here is a 3-way search tree:
 The algorithm for searching for a value in an M-way search
tree is the obvious generalization of the algorithm for
searching in a binary search tree.
Searching in M way tree
 If we are searching for value X are and currently at
node consisting of values V1...Vk, there are four
possible cases that can arise:
 If X < V1, recursively search for X in V1's left subtree.
 If X > Vk, recursively search for X in Vk's right subtree.
 If X=Vi, for some i, then we are done (X has been found).
 the only remaining possibility is that, for some i, Vi < X <
V(i+1). In this case recursively search for X in the subtree
that is in between Vi and V(i+1).
 M way tree used to reduce the height of the tree
 M way tree is not balanced tree.
 An extension of a multiway search tree of order m
is a B-tree of order m.
B tree
 To reduce the time lost in retrieving data from secondary storage,
we need to minimize the no. of references to the secondary memory.
 This is possible if a node in a tree contains more no. of values, then
in a single reference to the secondary memory more nodes can be
accessed.
 The AVL trees or red Black Trees can hold a max. of 1 value only in
a node while 2-3 Trees can hold a max of 2 values per node.
 To improve the efficiency Multiway Search Trees are used.
Properties
 A B Tree of order n is a Multiway Search Tree of order n with the
following characteristics:
 All the non leaf nodes have a max of n child nodes & a min of n/2 child
nodes.
 If a root is non leaf node, then it has a max of n non empty child nodes &
a min of 2 child nodes.
 If a root node is a leaf node, then it does not have any child node.
 A node with n child nodes has n-1 values arranged in ascending order.
 All values appearing on the left most child of any node are smaller than
the left most value of that node while all values appearing on the right
most child of any node are greater than the right most value of that node.
 If x & y are two adjacent values in a node such that x < y, ie they are the
i th & (i+1) th values in the node respectively, then all values in the (i+1) th
child of that node are > x but < y.
 A B-tree is an M-way search tree with two special
properties:
 It is perfectly balanced: every leaf node is at the same
depth.
 Every node, except perhaps the root, is at least half-
full, i.e. contains M/2 or more values (of course, it
cannot contain more than M-1 values). The root may
have any number of values (1 to M-1).
 The 3-way search tree above is clearly not a B-tree.
Here is a 3-way B-tree containing the same values:
Example
Operations
 THE following operations can be done on a B - Tree :
 Searching
 Insertion
 Deletion
SEARCHING OF A VALUE IN A B-TREE
 Searching of a value k in a B-Tree is exactly similar to
searching for values in a 2-3 tree.
 To begin with the value k is compared with the first
value key [0] of the root node.
 If they are similar then the search is complete.
 If k is less than key [0] then the search is done in the
first child node or the sub-tree of the root node.
Cont..
 If k is greater than key [0] then it is compared with key [1]. If k
is greater than key [0] and smaller than key [1] then k is
searched in the second child node or sub-tree of the root node.
 If k is greater than the last value key [i] of the root node then
searching is done in the last child node or sub-tree of the root
node.
 If k is searched in any of the child nodes or sub-tree of the
root node then the same procedure of searching is repeated
for that particular node or sub-tree.
Cont..
 If the value k is found in the tree then the search is
successful .
 The address of the node in which k is present and
the position of the value k in that node is returned.
 If the value k is not found in the tree, then the
search is unsuccessful
Unit 5 m way tree.pptxMMMMMMMMMMMMMMMMMMM
Cont..
Cont..
Cont..
Cont..
Unit 5 m way tree.pptxMMMMMMMMMMMMMMMMMMM
Unit 5 m way tree.pptxMMMMMMMMMMMMMMMMMMM
Unit 5 m way tree.pptxMMMMMMMMMMMMMMMMMMM
Unit 5 m way tree.pptxMMMMMMMMMMMMMMMMMMM
Unit 5 m way tree.pptxMMMMMMMMMMMMMMMMMMM
Unit 5 m way tree.pptxMMMMMMMMMMMMMMMMMMM
Example of B tree Creation
 Create a b tree of order 5 for following sequence
 3, 14, 7, 1, 8, 5, 11, 17, 13, 6, 23, 12, 20, 26, 4, 16, 18, 24, 25, 19
 Create a b tree of order 4 for following sequence
 92, 24, 6, 7, 11, 8, 22, 4, 5, 16, 19, 20, 78
 Create a b tree of order 5 for following sequence
 92, 24, 6, 7, 11, 8, 22, 4, 5, 16, 19, 20, 78
 Create a b tree of order 3 for following sequence
 20, 10, 30, 15, 12, 40, 50
 Create a b tree of order 3 for following sequence
 5, 3, 21, 9, 1, 13, 2, 7, 10, 12, 4, 8

More Related Content

PPTX
Multi ways trees
PPTX
Lecture 11 data structures and algorithms
PPTX
Data structures trees - B Tree & B+Tree.pptx
PPTX
12_m-way tree_Btree_Heapppppppppppppp.pptx
PPT
Binary Search Tree
PPT
Binary search tree(bst)
PPTX
10.m way search tree
PPT
Multiway Trees.ppt
Multi ways trees
Lecture 11 data structures and algorithms
Data structures trees - B Tree & B+Tree.pptx
12_m-way tree_Btree_Heapppppppppppppp.pptx
Binary Search Tree
Binary search tree(bst)
10.m way search tree
Multiway Trees.ppt

Similar to Unit 5 m way tree.pptxMMMMMMMMMMMMMMMMMMM (20)

PPSX
Unit-5 Advanced tree zxcppt
PPTX
Presentation on b trees [autosaved]
PPTX
Binary Search Tree
PPTX
Binary search tree definition operation.pptx
PPT
Best for b trees
PDF
B Tree, Introduction ,example,Splay tree
PPT
08 B Trees
PDF
BinarySearchTree-bddicken
PPTX
Binary search tree
PPTX
B+ tree.pptx
PPTX
Binary Search Tree In Python.pptx
PPTX
B trees
PDF
Trees, Binary Search Tree, AVL Tree in Data Structures
PPTX
Search tree,Tree and binary tree and heap tree
PPTX
Data Structures using Python(generic elective).pptx
PPT
Btree
PPTX
Binary Tree in Data Structure
PPTX
data structures module III & IV.pptx
PPTX
Binary Search Tree
PPT
BTrees-fall2010.ppt
Unit-5 Advanced tree zxcppt
Presentation on b trees [autosaved]
Binary Search Tree
Binary search tree definition operation.pptx
Best for b trees
B Tree, Introduction ,example,Splay tree
08 B Trees
BinarySearchTree-bddicken
Binary search tree
B+ tree.pptx
Binary Search Tree In Python.pptx
B trees
Trees, Binary Search Tree, AVL Tree in Data Structures
Search tree,Tree and binary tree and heap tree
Data Structures using Python(generic elective).pptx
Btree
Binary Tree in Data Structure
data structures module III & IV.pptx
Binary Search Tree
BTrees-fall2010.ppt
Ad

More from RAtna29 (20)

PPT
RedBlackTrees_2.pptNNNNNNNNNNNNNNNNNNNNNN
PPT
6Sorting.pptBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
PPTX
statisticsforsupportslides.pptxnnnnnnnnnnnnnnnnnn
PPT
Gerstman_PP09.pptvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
PPT
chapter8.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
PDF
MLT_KCS055 (Unit-2 Notes).pdfNNNNNNNNNNNNNNNN
PPTX
red black tree.pptxMMMMMMMMMMMMMMMMMMMMMMMMMM
PPTX
TF_IDF_PMI_Jurafsky.pptxnnnnnnnnnnnnnnnn
PPTX
13-DependencyParsing.pptxnnnnnnnnnnnnnnnnnnn
PPT
pos-tagging.pptbbbbbbbbbbbbbbbbbbbbnnnnnnnnnn
PPT
lecture_15.pptffffffffffffffffffffffffff
PPT
6640200.pptNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
PPT
Chapter 4.pptmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
PPT
cse220lec4.pptnnnnnnnnnnnnnnnnnnnnnnnnnnn
PPT
slp05.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnmmmmmmmmm
PPTX
lecture14-distributed-reprennnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnsentations.pptx
PPTX
lecture2-intro-boolean.pptbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbx
PPT
lecture10-efficient-scoring.ppmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmt
PPT
lecture3-indexconstruction.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
PPTX
lecture13-DTrees-textcat.pptxnnnnnnnnnnnnnnnnnnnnnn
RedBlackTrees_2.pptNNNNNNNNNNNNNNNNNNNNNN
6Sorting.pptBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
statisticsforsupportslides.pptxnnnnnnnnnnnnnnnnnn
Gerstman_PP09.pptvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
chapter8.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
MLT_KCS055 (Unit-2 Notes).pdfNNNNNNNNNNNNNNNN
red black tree.pptxMMMMMMMMMMMMMMMMMMMMMMMMMM
TF_IDF_PMI_Jurafsky.pptxnnnnnnnnnnnnnnnn
13-DependencyParsing.pptxnnnnnnnnnnnnnnnnnnn
pos-tagging.pptbbbbbbbbbbbbbbbbbbbbnnnnnnnnnn
lecture_15.pptffffffffffffffffffffffffff
6640200.pptNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
Chapter 4.pptmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
cse220lec4.pptnnnnnnnnnnnnnnnnnnnnnnnnnnn
slp05.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnmmmmmmmmm
lecture14-distributed-reprennnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnsentations.pptx
lecture2-intro-boolean.pptbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbx
lecture10-efficient-scoring.ppmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmt
lecture3-indexconstruction.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
lecture13-DTrees-textcat.pptxnnnnnnnnnnnnnnnnnnnnnn
Ad

Recently uploaded (20)

PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PPT
Total quality management ppt for engineering students
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
Soil Improvement Techniques Note - Rabbi
PPTX
communication and presentation skills 01
PPTX
UNIT - 3 Total quality Management .pptx
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Total quality management ppt for engineering students
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Abrasive, erosive and cavitation wear.pdf
Soil Improvement Techniques Note - Rabbi
communication and presentation skills 01
UNIT - 3 Total quality Management .pptx
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Visual Aids for Exploratory Data Analysis.pdf
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
Automation-in-Manufacturing-Chapter-Introduction.pdf
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Safety Seminar civil to be ensured for safe working.
Fundamentals of Mechanical Engineering.pptx
Exploratory_Data_Analysis_Fundamentals.pdf
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...

Unit 5 m way tree.pptxMMMMMMMMMMMMMMMMMMM

  • 2. Multiway Search Tree  A binary search tree has one value in each node and two subtrees.  A multiway tree is a tree that can have more than two children. A multiway tree of order m (or an m- way tree) is one in which a tree can have m children.  M is the order of the tree.
  • 4. Properties  By definition an m-way search tree is a m-way tree in which:  Each node has m children and m-1 key fields  The keys in each node are in ascending order.  The key of the data entries are ordered as key1<=key2<=<=key3………………..<keyk  All subtree are them seleves multiway trees.  The keys in the first i children are smaller than the i th key  The keys in the last m-i children are larger than the i th key
  • 5. Example  Here is a 3-way search tree:  The algorithm for searching for a value in an M-way search tree is the obvious generalization of the algorithm for searching in a binary search tree.
  • 6. Searching in M way tree  If we are searching for value X are and currently at node consisting of values V1...Vk, there are four possible cases that can arise:  If X < V1, recursively search for X in V1's left subtree.  If X > Vk, recursively search for X in Vk's right subtree.  If X=Vi, for some i, then we are done (X has been found).  the only remaining possibility is that, for some i, Vi < X < V(i+1). In this case recursively search for X in the subtree that is in between Vi and V(i+1).
  • 7.  M way tree used to reduce the height of the tree  M way tree is not balanced tree.  An extension of a multiway search tree of order m is a B-tree of order m.
  • 8. B tree  To reduce the time lost in retrieving data from secondary storage, we need to minimize the no. of references to the secondary memory.  This is possible if a node in a tree contains more no. of values, then in a single reference to the secondary memory more nodes can be accessed.  The AVL trees or red Black Trees can hold a max. of 1 value only in a node while 2-3 Trees can hold a max of 2 values per node.  To improve the efficiency Multiway Search Trees are used.
  • 9. Properties  A B Tree of order n is a Multiway Search Tree of order n with the following characteristics:  All the non leaf nodes have a max of n child nodes & a min of n/2 child nodes.  If a root is non leaf node, then it has a max of n non empty child nodes & a min of 2 child nodes.  If a root node is a leaf node, then it does not have any child node.  A node with n child nodes has n-1 values arranged in ascending order.  All values appearing on the left most child of any node are smaller than the left most value of that node while all values appearing on the right most child of any node are greater than the right most value of that node.  If x & y are two adjacent values in a node such that x < y, ie they are the i th & (i+1) th values in the node respectively, then all values in the (i+1) th child of that node are > x but < y.
  • 10.  A B-tree is an M-way search tree with two special properties:  It is perfectly balanced: every leaf node is at the same depth.  Every node, except perhaps the root, is at least half- full, i.e. contains M/2 or more values (of course, it cannot contain more than M-1 values). The root may have any number of values (1 to M-1).  The 3-way search tree above is clearly not a B-tree. Here is a 3-way B-tree containing the same values:
  • 12. Operations  THE following operations can be done on a B - Tree :  Searching  Insertion  Deletion
  • 13. SEARCHING OF A VALUE IN A B-TREE  Searching of a value k in a B-Tree is exactly similar to searching for values in a 2-3 tree.  To begin with the value k is compared with the first value key [0] of the root node.  If they are similar then the search is complete.  If k is less than key [0] then the search is done in the first child node or the sub-tree of the root node.
  • 14. Cont..  If k is greater than key [0] then it is compared with key [1]. If k is greater than key [0] and smaller than key [1] then k is searched in the second child node or sub-tree of the root node.  If k is greater than the last value key [i] of the root node then searching is done in the last child node or sub-tree of the root node.  If k is searched in any of the child nodes or sub-tree of the root node then the same procedure of searching is repeated for that particular node or sub-tree.
  • 15. Cont..  If the value k is found in the tree then the search is successful .  The address of the node in which k is present and the position of the value k in that node is returned.  If the value k is not found in the tree, then the search is unsuccessful
  • 27. Example of B tree Creation  Create a b tree of order 5 for following sequence  3, 14, 7, 1, 8, 5, 11, 17, 13, 6, 23, 12, 20, 26, 4, 16, 18, 24, 25, 19  Create a b tree of order 4 for following sequence  92, 24, 6, 7, 11, 8, 22, 4, 5, 16, 19, 20, 78  Create a b tree of order 5 for following sequence  92, 24, 6, 7, 11, 8, 22, 4, 5, 16, 19, 20, 78  Create a b tree of order 3 for following sequence  20, 10, 30, 15, 12, 40, 50  Create a b tree of order 3 for following sequence  5, 3, 21, 9, 1, 13, 2, 7, 10, 12, 4, 8