Download presentation
Presentation is loading. Please wait.
Published byFarida Kusuma Modified over 5 years ago
1
m-Way Search Trees A m-way Search tree of degree ‘m’ can have
at most m child nodes. If a node has k child nodes, then the node can have only (k-1) keys contained in the node. For a node A0, (K1, A1), (K2, A2)……………. ..(Km-1, Am-1), all key value in the sub-tree pointed to by Ai are less than the key Ki+1, and all key values in the sub-tree pointed to by Am-1 are greater than Km-1.
2
Example 2 : 22 25 5 10 14 27
3
m-Way searching : Similar to Binary searching What about if d>2 ?
If search item s<k1 search the leftmost child. If search item s>k(d-1), search the rightmost child What about if d>2 ? Find two keys k(i-1) and k(i) between which s falls, and search the item in that node.
4
m-Way searching : Search for 8 Search for 12 22 25 5 10 3 4 6 8 14
5 10 14 27
5
What would an in-order traversal look like :
22 25 5 10 14 27 3, 4, 5, 6, 8, 10, 11, 13, 14, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27
6
Properties (2, 4) Tree It is a kind of m-way search tree.
12 At most 4 children All leaf are at same level 15 11 17
7
Insertion in m-way search tree :
STEPS : Search the node where the key is to be inserted. If the searched node is not full then insert the key into that node. If the searched node is full then open a new child node and insert the key.
8
Insertion in m-way search tree :
Since 6<18 TO INSERT 6 X X Since 6<7 & node is not full 6 will be inserted at this node. 7 12 80 92 141 262 X X X X X 8 12 77 148 151 172 186 272 286 350 X X X X X X X X X X X X X X
9
Insertion in m-way search tree :
To insert 6 X X 7 12 80 92 141 262 X X X X X 8 12 77 148 151 172 186 272 286 350 X X X X X X X X X X X X X X
10
Insertion in m-way search tree :
TO INSERT 6 X X 7 12 80 92 141 262 X X X X X 8 12 77 148 151 172 186 272 286 350 X X X X X X X X X X X X X X
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.