Presentation is loading. Please wait.

Presentation is loading. Please wait.

Main Index Contents 11 Main Index Contents Abstract Model of a List Obj. Abstract Model of a List Obj. Insertion into a List Insertion into a List Linked.

Similar presentations


Presentation on theme: "Main Index Contents 11 Main Index Contents Abstract Model of a List Obj. Abstract Model of a List Obj. Insertion into a List Insertion into a List Linked."— Presentation transcript:

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

2 Main Index Contents 2 Abstract Model of a List Object

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

4 Main Index Contents 44 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 Main Index Contents 55 Main Index Contents Linked List Nodes Removal is like Insertion in reverse.

6 Main Index Contents 66 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 Main Index Contents 77 Main Index Contents Inserting at the Front of a Linked List

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

9 Main Index Contents 99 Main Index Contents Removing a Target Node

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

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

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

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

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

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

16 Main Index Contents 16 Updating a Doubly Linked List

17 Main Index Contents 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 Main Index Contents 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 Main Index Contents 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 Main Index Contents 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 Main Index Contents 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.


Download ppt "Main Index Contents 11 Main Index Contents Abstract Model of a List Obj. Abstract Model of a List Obj. Insertion into a List Insertion into a List Linked."

Similar presentations


Ads by Google