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

Post on 18-Jan-2016

218 views 0 download

Tags:

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

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 “ .

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

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

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

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

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

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

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

Left Child-Right Sibling Representation

Change to binary treeA

B C D

E F G H I J

K L M

Left Child-Right Sibling Representation

Change to binary treeA

BC D

E F G H I J

K L M

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E F G H I J

K L M

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F G H I J

K L M

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F

G H I J

K L M

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F

G H I J

K

L M

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F

G H I J

K

L M

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F GH I J

K

L M

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F GH I J

K

LM

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F G

H

I J

K

LM

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F G

H

I J

K

L

M

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F G

H

I

J

K

L

M

Left Child-Right Sibling Representation

Change to binary treeA

B

C

D

E

F G

H

IJ

K

L

M