Top Banner
1
31

Grapical View Double Linked Lists

Feb 24, 2016

Download

Documents

baxter

Grapical View Double Linked Lists. Dr. Thomas E. Hicks Computer Science Dept Trinity University. 1. Nodes & HeaderNodes Doubly Linked List. DA_DLList < PartListHeader , Part> Inventory ( " Inventory.hf ", "Inventory.nf", 3, 4);. DLList < PartListHeader , Part> - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Grapical  View  Double Linked Lists

1

Page 2: Grapical  View  Double Linked Lists

Nodes &HeaderNodes

Doubly Linked List

2

Page 3: Grapical  View  Double Linked Lists

Graphical Representation Of HeadersDA_DLList <PartListHeader, Part>

Inventory ( "Inventory.hf", "Inventory.nf", 3, 4);

DLList <PartListHeader, Part> Inventory (3, 4);

1

/ /0

2

/ /0

/ /0

3

1 2 3 4

3

Page 4: Grapical  View  Double Linked Lists

Avail PoolDoubly Linked List

4

Page 5: Grapical  View  Double Linked Lists

Graphical Representation Of Nodes & HeadersDA_DLList <PartListHeader, Part>

Inventory ( "Inventory.hf", "Inventory.nf", 3, 4);

DLList <PartListHeader, Part> Inventory (3, 4);

1 2 3 4

1

5

Page 6: Grapical  View  Double Linked Lists

PushDoubly Linked List

Push Places Nodes At The Front Of The Linked List

2 Cases

6

Page 7: Grapical  View  Double Linked Lists

if (Inventory.Push (3, D))puts (“Successful Push”);

elseputs (“Unsuccessful Push”);

/ /0

3 3 1 2

3 31

3

3

1 2

D

Push To An Empty List7

Page 8: Grapical  View  Double Linked Lists

if (Inventory.Push (3, R))puts (“Successful Push”);

elseputs (“Unsuccessful Push”);

3 31

3

31 2

D

First Push To A Non-Empty List

1 32

3

1R

3D 3 1

2

8

Page 9: Grapical  View  Double Linked Lists

if (Inventory.Push (3, A))puts (“Successful Push”);

elseputs (“Unsuccessful Push”);

Second Push To A Non-Empty List

1 32

3

1R

3D 3 1

2

1R

3D 3

1 32

3

1

/

2 33

3

2A R 1 2 1 3

9

Page 10: Grapical  View  Double Linked Lists

PopDoubly Linked List

Pop Deletes From The Front Of The Linked List

2 Cases

10

Page 11: Grapical  View  Double Linked Lists

if (Inventory.Pop (3, Temp))cout << Temp << endl;

elseputs (“Unsuccessful Pop”);

First Pop From A Non-Empty List

1R

3D 3

1 32

3

1

/

2 33

3

2A R 1 2 1 3

Temp = Old Info = A1 32

3

1R

3D 3 1

2A

11

Page 12: Grapical  View  Double Linked Lists

if (Inventory.Pop (3, Temp))cout << Temp << endl;

elseputs (“Unsuccessful Pop”);

Second Pop From A Non-Empty List

1 32

3

1R

3D 3 1

2

A

Temp = OldInfo = R3 31

3

31 2

D R A

12

Page 13: Grapical  View  Double Linked Lists

if (Inventory.Pop (3, Temp))cout << Temp << endl;

elseputs (“Unsuccessful Pop”);

3 31

3

3

1 2

D

Pop The Last Node From A List

Temp = Old Info = D

AR

/ /0

3 3 1 2ARD

13

Page 14: Grapical  View  Double Linked Lists

InsertDoubly Linked List

Insert Places Nodes At The Rear Of The Linked List

2 Cases

14

Page 15: Grapical  View  Double Linked Lists

if (Inventory.Insert (3, D))puts (“Successful Insert”);

elseputs (“Unsuccessful Insert”);

/ /0

3 3 1 2

3 31

3

3

1 2

D

Insert To An Empty List15

Page 16: Grapical  View  Double Linked Lists

if (Inventory.Insert (3, R))puts (“Successful Insert”);

elseputs (“Unsuccessful Insert”);

3 31

3

31 2

D

First Insert To A Non-Empty List

3 12

3

3D

1R 1 3

2

16

Page 17: Grapical  View  Double Linked Lists

if (Inventory.Insert (3, A))puts (“Successful Insert”);

elseputs (“Unsuccessful Insert”);

Second Insert To A Non-Empty List

3 12

3

3D

1R 1 3

2

1R

2A 3

1 32

3

1

/

3 23

3

3D R 1 3 1 2

17

Page 18: Grapical  View  Double Linked Lists

RemoveDoubly Linked List

Remove Deletes From The Front Of The Linked List

2 Cases

18

Page 19: Grapical  View  Double Linked Lists

if (Inventory.Remove (3, Temp))cout << Temp << endl;

elseputs (“Unsuccessful Remove”);

First Remove From A Non-Empty List

1R

2A 3

1 32

3

1

/

3 23

3

3D R 1 3 1 2

1 22

3

1 2A 2 1

3D

R

Temp = Old Info = D

19

Page 20: Grapical  View  Double Linked Lists

if (Inventory.Remove (3, Temp))cout << Temp << endl;

elseputs (“Unsuccessful Remove”);

Second Remove From A Non-Empty List

Temp = OldInfo = R2 21

3

21 3

A R D

1 22

3

1 2A 2 1

3D

R

20

Page 21: Grapical  View  Double Linked Lists

if (Inventory.Remove (3, Temp))cout << Temp << endl;

elseputs (“Unsuccessful Remove”);

2 21

3

2

1 3

A

Remove The Last Node From A List

Temp = Old Info = A

DR

/ /0

3 2 1 3DRA

21

Page 22: Grapical  View  Double Linked Lists

InsertAfterDoubly Linked List

InsertAfter Places Nodes To The Right Of The Right-Brother

2 Cases

22

Page 23: Grapical  View  Double Linked Lists

if (Inventory.InsertAfter (3, T, 4))puts (“Successful InsertAfter”);

elseputs (“Unsuccessful InsertAfter”);

InsertAfter To The Middle Of A List

1

1R

3Y 3

1 32

3

42 33

3

2C R 4 2 4 3

1R

3Y 3

1 32

3

42 34

3

2C R 4 2 11

/

1T4 3

23

Page 24: Grapical  View  Double Linked Lists

if (Inventory.InsertAfter (3, Z, 4))puts (“Successful InsertAfter”);

elseputs (“Unsuccessful InsertAfter”);

InsertAfter To The End Of A List

1

1R

3Y 3

1 32

3

42 33

3

2C R 4 2 4 3

1R

1Z 3

1 32

3

42 14

3

2C R 4 2 31

/

3Y4 1

24

Page 25: Grapical  View  Double Linked Lists

InplaceDoubly Linked List

Inplace Places Nodes Inplace According To The Primary Object Overload

4 Cases

25

Page 26: Grapical  View  Double Linked Lists

if (Inventory.Inplace (3, D))puts (“Successful Inplace”);

elseputs (“Unsuccessful Inplace”);

/ /0

3 3 1 2

Inplace On An Empty List

Insert

Push

4

3 31

3

3

D

1 24

26

Page 27: Grapical  View  Double Linked Lists

if (Inventory.Inplace (3, A))puts (“Successful Inplace”);

elseputs (“Unsuccessful Inplace”);

3 31

3

3

D

Inplace To Front Of A List

Push

1 24

4 32

3

4A

3D 3 4

1 2

27

Page 28: Grapical  View  Double Linked Lists

if (Inventory.Inplace (3, H))puts (“Successful Inplace”);

elseputs (“Unsuccessful Inplace”);

Inplace To The End Of A List

4 32

3

4A

3D 3 4

1 2

1R

1H 3

1 32

3

34 13

3

4A D 3 4 3 1

2

Insert

28

Page 29: Grapical  View  Double Linked Lists

if (Inventory.Inplace (3, F))puts (“Successful Inplace”);

elseputs (“Unsuccessful Inplace”);

Inplace To The Middle Of A List

1R

1H 3

1 32

3

34 13

3

4A D 1 4 3 1

2

1R

1H 3

1 32

3

34 14

3

4A D 3 4 22

/

2F3 1

InsertAfter

29

Page 30: Grapical  View  Double Linked Lists

Nodes & HeaderNodes

Page 31: Grapical  View  Double Linked Lists

Nodes & HeaderNodes