06. M-Way Search Tree
-
Upload
akif-vohra -
Category
Documents
-
view
415 -
download
0
Transcript of 06. M-Way Search Tree
(C) GOYANI MAHESH(C) GOYANI MAHESH 11
DATA STRUCTURE
S
MAHESH GOYANIMAHATMA GANDHI INSTITUE OF TECHNICAL EDUCATION & RESEARCH CENTER
(C) GOYANI MAHESH(C) GOYANI MAHESH 22
M-WAY SEARCH
TREE
(C) GOYANI MAHESH(C) GOYANI MAHESH 33
Tree having m-1 key and m children is called m-way search tree.
A binary tree is a 2-way tree. It means it has m-1 = 2-1 = 1 key and maximum 2 child.
A Binary Tree is called m-way tree of order 2.
9 20 41
9 20
9 9 20 41
9
9 20
9
9 20 41
TERMINOLOGY
(C) GOYANI MAHESH(C) GOYANI MAHESH 44
2-3SEARCH
TREE
(C) GOYANI MAHESH(C) GOYANI MAHESH 55
TERMINOLOGY
Every node in 2-3 tree has two or three children.
A 2-3 tree is a tree in which leaf nodes are the only nodes that contains data values.
All leaf nodes contains two values.
The first value in non-leaf node is the maximum value of its left subtree.
The second value of non-leaf node is the maximum value of its middle (or right) tree.
(C) GOYANI MAHESH(C) GOYANI MAHESH 66
13
insert (13)
(C) GOYANI MAHESH(C) GOYANI MAHESH 77
13
insert (41)
41
13 : 41
(C) GOYANI MAHESH(C) GOYANI MAHESH 88
13
insert (21)
41
13 : 41
21
(C) GOYANI MAHESH(C) GOYANI MAHESH 99
insert (7)
13 : 41
7 13 21 41
7 : 13 21 : 41
(C) GOYANI MAHESH(C) GOYANI MAHESH 1010
insert (18), insert (39)
13 : 41
7 18 21 41
7 : 13 21 : 41
13 39
7 : 13 21 : 39