Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer :...

21
Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer Shao-Huan Wang The ideas are reference to the textbook “Fundamentals of Data Structures in C “ .

Transcript of Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer :...

Page 1: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Instructor : Prof. Jyh-Shing Roger Jang

Designer : Shao-Huan WangThe ideas are reference to the textbook “Fundamentals of Data Structures in C “ .

Page 2: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

A

B C D

E F G H I J

K L M

Replaced by the left child-right sibling representation

A

Put the left child node to the node’sleft link

B

Put the sibling to the node’s right link

C D

Page 3: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

A

B C D

E F G H I J

K L M

Replaced by the left child-right sibling representation

A

Put the left child node to the node’sleft link

B

Put the sibling to the node’s right link

C D

E F

Page 4: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

A

B C D

E F G H I J

K L M

Replaced by the left child-right sibling representation

A

Put the left child node to the node’sleft link

B

Put the sibling to the node’s right link

C D

E F G

Page 5: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

A

B C D

E F G H I J

K L M

Replaced by the left child-right sibling representation

A

Put the left child node to the node’sleft link

B

Put the sibling to the node’s right link

C D

E F G H I J

Page 6: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

A

B C D

E F G H I J

K L M

Replaced by the left child-right sibling representation

A

Put the left child node to the node’sleft link

B

Put the sibling to the node’s right link

C D

E F G H I J

K L

Page 7: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

A

B C D

E F G H I J

K L M

Replaced by the left child-right sibling representation

A

Put the left child node to the node’sleft link

B

Put the sibling to the node’s right link

C D

E F G H I J

K L M

Page 8: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Replaced by the left child-right sibling representation Put the left child node to the node’sleft link Put the sibling to the node’s right link

A

B C D

E F G H I J

K L MUse a structure to link each node

A

B C D

N

E F G H I J

K L M

N

N NN

N

N NN

N NNN

N

N::=link to NULL

Page 9: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B C D

E F G H I J

K L M

Page 10: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

BC D

E F G H I J

K L M

Page 11: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E F G H I J

K L M

Page 12: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F G H I J

K L M

Page 13: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F

G H I J

K L M

Page 14: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F

G H I J

K

L M

Page 15: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F

G H I J

K

L M

Page 16: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F GH I J

K

L M

Page 17: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F GH I J

K

LM

Page 18: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F G

H

I J

K

LM

Page 19: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F G

H

I J

K

L

M

Page 20: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F G

H

I

J

K

L

M

Page 21: Left Child-Right Sibling Representation Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F G

H

IJ

K

L

M