Presentation is loading. Please wait.

Presentation is loading. Please wait.

C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.

Similar presentations


Presentation on theme: "C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists."— Presentation transcript:

1 C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists

2

3 Doubly linked list: every node has next and back pointers Can be traversed in either direction

4 Doubly Linked Lists (continued) Operations: 1.Initialize the list. 2.Destroy the list. 3.Determine whether the list is empty. 4.Search the list for a given item. 5.Retrieve the first element of the list. 6.Retrieve the last element of the list. 7.Insert an item in the list. 8.Delete an item from the list. 9.Find the length of the list. 10.Print the list. 11.Make a copy of the doubly linked list.

5

6

7

8

9

10

11

12 Both cases 1 and 2 require us to change the value of the pointer first. Cases 3 and 4 are similar. After inserting an item, count is incremented by 1. Next, we show Case 4.

13

14 After deleting a node, count is decremented by 1. Let us demonstrate Case 3.

15

16

17

18 Operations on a circular list are: 1.Initialize the list (to an empty state). 2.Determine if the list is empty. 3.Destroy the list. 4.Print the list. 5.Find the length of the list. 6.Search the list for a given item. 7.Insert an item in the list. 8.Delete an item from the list. 9.Copy the list.

19 Programming Example A new video store in your neighborhood is about to open However, it does not have a program to keep track of its videos and customers The store managers want someone to write a program for their system so that the video store can operate

20 Programming Example (continued) The program should be able to perform the following operations: −Rent a video; that is, check out a video −Return, or check in, a video −Create a list of videos owned by the store −Show the details of a particular video −Print a list of all videos in the store −Check whether a particular video is in the store −Maintain a customer database −Print list of all videos rented by each customer

21 Programming Example (continued) There are two major components of the video store: −A video −A customer You need to maintain two lists: 1.A list of all videos in the store 2.A list of all customers of the store

22 Part 1: Video Component (continued) The common things associated with a video are: −Name of the movie −Names of the stars −Name of the producer −Name of the director −Name of the production company −Number of copies in store


Download ppt "C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists."

Similar presentations


Ads by Google