310 likes | 415 Views
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>
E N D
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> Inventory (3, 4); Graphical Representation Of Headers 1 0 / / 2 0 / / 3 0 / / 1 2 3 4
Avail Pool Doubly Linked List
DA_DLList <PartListHeader, Part> Inventory ( "Inventory.hf", "Inventory.nf", 3, 4); DLList <PartListHeader, Part> Inventory (3, 4); Graphical Representation Of Nodes & Headers 1 2 3 4 1
2 Cases PushDoubly Linked List Push Places Nodes At The Front Of The Linked List
Push To An Empty List if (Inventory.Push (3, D)) puts (“Successful Push”);else puts (“Unsuccessful Push”); 3 1 2 3 3 3 1 0 / 3 / 3 D 1 2
First Push To A Non-Empty List if (Inventory.Push (3, R)) puts (“Successful Push”);else puts (“Unsuccessful Push”); 3 1 2 D 3 3 1 3 2 1 1 3 3 3 3 1 R D 2
Second Push To A Non-Empty List if (Inventory.Push (3, A)) puts (“Successful Push”);else puts (“Unsuccessful Push”); 3 3 3 1 3 3 2 2 1 2 1 3 3 3 1 2 1 3 3 1 R D R 3 1 1 3 2 D R A 2 /
2 Cases Pop Doubly Linked List Pop Deletes From The Front Of The Linked List
First Pop From A Non-Empty List if (Inventory.Pop (3, Temp))cout << Temp << endl;else puts (“Unsuccessful Pop”); Temp = Old Info = A 3 3 3 1 3 2 2 3 1 2 1 3 3 3 1 1 2 3 3 1 R D R 3 1 3 1 2 D A R 2 / A
Second Pop From A Non-Empty List if (Inventory.Pop (3, Temp))cout << Temp << endl;else puts (“Unsuccessful Pop”); A Temp = OldInfo = R 3 3 1 3 2 1 1 3 3 3 3 3 1 R D 1 2 D R A 2
Pop The Last Node From A List if (Inventory.Pop (3, Temp))cout << Temp << endl;else puts (“Unsuccessful Pop”); 3 1 2 R A 3 3 Temp = Old Info = D 3 1 0 / 3 / 3 D D R A 1 2
2 Cases Insert Doubly Linked List Insert Places Nodes At The Rear Of The Linked List
Insert To An Empty List if (Inventory.Insert (3, D)) puts (“Successful Insert”);else puts (“Unsuccessful Insert”); 3 1 2 3 3 3 1 0 / 3 / 3 D 1 2
First Insert To A Non-Empty List if (Inventory.Insert (3, R)) puts (“Successful Insert”);else puts (“Unsuccessful Insert”); 3 1 2 D 3 3 3 1 2 1 3 3 3 1 1 3 D R 2
Second Insert To A Non-Empty List if (Inventory.Insert (3, A)) puts (“Successful Insert”);else puts (“Unsuccessful Insert”); 3 3 3 3 1 3 2 2 1 3 3 2 3 1 1 3 1 2 1 3 D R R 2 1 1 3 3 A R D 2 /
2 Cases Remove Doubly Linked List Remove Deletes From The Front Of The Linked List
First Remove From A Non-Empty List if (Inventory.Remove (3, Temp))cout << Temp << endl;else puts (“Unsuccessful Remove”); Temp = Old Info = D 3 3 3 2 2 3 1 3 1 2 2 3 1 1 1 3 2 2 R R 2 1 2 3 1 1 3 A R D A 3 / D
Second Remove From A Non-Empty List if (Inventory.Remove (3, Temp))cout << Temp << endl;else puts (“Unsuccessful Remove”); Temp = OldInfo = R 3 3 1 2 2 1 2 2 1 2 2 R 2 1 A 1 3 A R D 3 D
Remove The Last Node From A List if (Inventory.Remove (3, Temp))cout << Temp << endl;else puts (“Unsuccessful Remove”); 2 1 3 R D 3 3 Temp = Old Info = A 2 1 0 / 2 / 2 A A R D 1 3
2 Cases InsertAfterDoubly Linked List InsertAfter Places Nodes To The Right Of The Right-Brother
InsertAfter To The Middle Of A List if (Inventory.InsertAfter (3, T, 4)) puts (“Successful InsertAfter”);else puts (“Unsuccessful InsertAfter”); 4 2 1 3 R 3 4 3 4 2 Y C R 1 3 3 3 3 3 2 2 4 2 1 1 2 3 3 3 3 4 1 2 1 3 R 1 T 3 1 Y 4 3 2 4 C R /
InsertAfter To The End Of A List if (Inventory.InsertAfter (3, Z, 4)) puts (“Successful InsertAfter”);else puts (“Unsuccessful InsertAfter”); 4 2 1 3 R 3 4 3 4 2 Y C R 1 3 3 3 3 3 2 2 4 2 1 1 2 3 1 3 3 4 3 2 1 1 R 1 Y 1 3 Z 4 3 2 4 C R /
4 Cases InplaceDoubly Linked List Inplace Places Nodes Inplace According To The Primary Object Overload
Inplace On An Empty List if (Inventory.Inplace (3, D)) puts (“Successful Inplace”);else puts (“Unsuccessful Inplace”); 4 3 1 2 Insert 3 3 Push 3 1 0 3 / / 3 D 4 1 2
Inplace To Front Of A List if (Inventory.Inplace (3, A)) puts (“Successful Inplace”);else puts (“Unsuccessful Inplace”); 3 4 1 2 D Push 3 3 4 3 1 2 3 4 3 3 3 4 A D 1 2
Inplace To The End Of A List if (Inventory.Inplace (3, H)) puts (“Successful Inplace”);else puts (“Unsuccessful Inplace”); 4 3 3 4 A D 1 2 Insert 3 3 3 2 3 2 1 4 4 3 1 3 3 1 4 1 D 1 3 3 3 4 H R A 2
Inplace To The Middle Of A List if (Inventory.Inplace (3, F)) puts (“Successful Inplace”);else puts (“Unsuccessful Inplace”); 3 1 4 1 D 1 3 3 1 4 H A R 2 InsertAfter 3 3 3 3 3 2 4 2 1 4 4 1 1 3 1 3 3 2 1 4 1 D 2 F 1 2 H 3 3 4 3 R A /