1 / 21

Main Index

Chapter 9 – Linked Lists. 1. Main Index. Contents. Abstract Model of a List Obj. Insertion into a List Linked List (LL) nodes (2 slides) Node Composition Inserting at the Front of a LL Deleting from the Front of a LL Removing a Target Node. Handling the Back of the List

Download Presentation

Main Index

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 9 – Linked Lists 1 Main Index Contents • Abstract Model of a List Obj. • Insertion into a List • Linked List (LL) nodes (2 slides) • Node Composition • Inserting at the Front of a LL • Deleting from the Front of a LL • Removing a Target Node • Handling the Back of the List • Designing a New LL Structure • Inserting a Node at a Position • (2 slides) • Circular Doubly LL’s (2 slides) • Updating a Doubly LL • Summary Slides (5 slides)

  2. Abstract Model of a List Object

  3. 3 Main Index Contents Insertion Into a List by Shifting Vector Storage Elements

  4. 4 Main Index Contents Linked List Nodes • Each Node is like a piece of a chain • To insert a new link, break the chain at the desired location and simply reconnect at both ends of the new piece.

  5. 5 Main Index Contents Linked List Nodes • Removal is like Insertion in reverse.

  6. 6 Main Index Contents Node Composition • An individual Node is composed of two parts, a Data field containing the data stored by the node, and a Pointer field that marks the address of the next Node in the list.

  7. 7 Main Index Contents Inserting at the Front of a Linked List

  8. 8 Main Index Contents Deleting From the Front of a Linked List

  9. 9 Main Index Contents Removing a Target Node

  10. 10 Main Index Contents Handling the Back of the List

  11. 11 Main Index Contents Designing a New Linked List Structure

  12. 12 Main Index Contents Inserting a Node at a Position

  13. 13 Main Index Contents Inserting a Node at a Position

  14. 14 Main Index Contents Circular Doubly Linked Lists • A Watch Band provides a good Real Life analogue for this Data Structure

  15. 15 Main Index Contents Circular Doubly Linked Lists • Implemented on a Computer it might look something like this.

  16. Updating a Doubly Linked List

  17. 17 Main Index Contents Summary Slide 1 §-singly linked lists - Each node contains a value and a pointer to the next node in the list. - The list begins with a pointer to the first node of the list and terminates when a node has a NULL pointer.

  18. 18 Main Index Contents Summary Slide 2 §-Inserting/Deleting at the front of a singly linked list 1) Insert - Set the pointer in the new node to the previous value of front. - update front to point at the new node. 2) Erase - assign front the pointer value of the first node, and then delete the node.

  19. 19 Main Index Contents Summary Slide 3 §-Inserting/Erasing inside a singly linked list - Maintain a pointer to the current list node and a pointer to the previous node. - Change the pointer value in the previous node.

  20. 20 Main Index Contents Summary Slide 4 §-Insert/Delete at the back of a singly linked list - Maintain a pointer to the last list node that has value NULL when the list is empty. - Assign a “back” pointer the address of the first node added to the list. - To add other nodes at the back: 1) allocate a new node 2) assign the pointer in node “back” to point to the new node 3) assign the pointer “back” the address of the new node.

  21. 21 Main Index Contents Summary Slide 5 §-Doubly linked lists - provide the most flexible implementation for the sequential list. §- Its nodes have pointers to the next and the previous node, so the program can traverse a list in either the forward or backward direction. - Traverse a list by starting at the first node and follow the sequence of next nodes until you arrive back at the header. - To traverse a list in reverse order, start at the last node and follow the sequence of previous nodes until arriving back at the header.

More Related