06. M-Way Search Tree

10
(C) GOYANI MAHESH (C) GOYANI MAHESH 1 DATA STRUCTURES MAHESH GOYANI MAHATMA GANDHI INSTITUE OF TECHNICAL EDUCATION & RESEARCH CENTER [email protected]

Transcript of 06. M-Way Search Tree

Page 1: 06. M-Way Search Tree

(C) GOYANI MAHESH(C) GOYANI MAHESH 11

DATA STRUCTURE

S

MAHESH GOYANIMAHATMA GANDHI INSTITUE OF TECHNICAL EDUCATION & RESEARCH CENTER

[email protected]

Page 2: 06. M-Way Search Tree

(C) GOYANI MAHESH(C) GOYANI MAHESH 22

M-WAY SEARCH

TREE

Page 3: 06. 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

Page 4: 06. M-Way Search Tree

(C) GOYANI MAHESH(C) GOYANI MAHESH 44

2-3SEARCH

TREE

Page 5: 06. M-Way Search 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.

Page 6: 06. M-Way Search Tree

(C) GOYANI MAHESH(C) GOYANI MAHESH 66

13

insert (13)

Page 7: 06. M-Way Search Tree

(C) GOYANI MAHESH(C) GOYANI MAHESH 77

13

insert (41)

41

13 : 41

Page 8: 06. M-Way Search Tree

(C) GOYANI MAHESH(C) GOYANI MAHESH 88

13

insert (21)

41

13 : 41

21

Page 9: 06. M-Way Search Tree

(C) GOYANI MAHESH(C) GOYANI MAHESH 99

insert (7)

13 : 41

7 13 21 41

7 : 13 21 : 41

Page 10: 06. M-Way Search Tree

(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