C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists (part 3)

Slides:



Advertisements
Similar presentations
TK1924 Program Design & Problem Solving Session 2011/2012
Advertisements

Linked Lists Geletaw S..
My EBSCOhost Tutorial Tutorial support.ebsco.com.
DATA STRUCTURES USING C++ Chapter 5
Linked Lists Linked Lists Representation Traversing a Linked List
Data Structures Using C++
Chapter 17 Linked List Saurav Karmakar Spring 2007.
M180: Data Structures & Algorithms in Java
Foundation of Computing Systems Lecture 2 Linked Lists.
Data Structures: A Pseudocode Approach with C
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Contd... Objectives Explain the design, use, and operation of a linear list Implement a linear.
Data Structures & Algorithms
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
C++ Programming: Program Design Including Data Structures, Second Edition Chapter 17: Linked Lists.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
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.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 20: Binary Trees.
Data Structures Using C++ 2E
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 19: Searching and Sorting Algorithms.
Data Structures Using Java1 Chapter 4 Linked Lists.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Department of Computer Science Data Structures Using C++ 2E Chapter 5 Linked Lists.
Linked List. Iterators Operation to find a link, deleting, and inserting before or after a specified link, also involve searching through the list to.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 17: Linked Lists.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
BlockWood Video 1. Handle rentals and purchases 2. Save all transactions to the database 3. Manage accounts and members 4. Refund items 5. Provide premium.
Linked List Chapter Data Abstraction separates the logical properties of a data type from its implementation LOGICAL PROPERTIES – What are the.
Linked List by Chapter 5 Linked List by
Subject Name : Data Structure Using C Title : Linked Lists
Data Structures Using C++1 Chapter 5 Linked Lists.
CS2006- Data Structures I Chapter 5 Linked Lists III.
1. Circular Linked List In a circular linked list, the last node contains a pointer to the first node of the list. In a circular linked list,
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists (part 2)
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 18: Linked Lists (part 2)
1 Algorithms Queues, Stacks and Records stored in Linked Lists or Arrays.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
Department of Computer Science 1 Some Practice Let’s practice for the final a little bit. OK?
 Array is a data structure were elements are stored in consecutive memory location.in the array once the memory is allocated.it cannot be extend any more.
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
CS162 - Topic #7 Lecture: Dynamic Data Structures –Review of pointers and the new operator –Introduction to Linked Lists –Begin walking thru examples of.
Chapter 17: Linked Lists. Objectives In this chapter, you will: – Learn about linked lists – Learn the basic properties of linked lists – Explore insertion.
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
Data Structure & Algorithms
Copyright  Oracle Corporation, All rights reserved. 1 CMIS Powell Oracle Designer: Process Modeling CMIS Powell.
Single Linked Lists Objectives In this lesson, you will learn to: *Define single linked list *Identify the following types of linked lists: Single linked.
1 CS 132 Spring 2008 Chapter 5 Linked Lists p
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 18: Linked Lists.
CHAPTER 51 LINKED LISTS. Introduction link list is a linear array collection of data elements called nodes, where the linear order is given by means of.
  A linked list is a collection of components called nodes  Every node (except the last one) contains the address of the next node  The address of.
UNIT-II Topics to be covered Singly linked list Circular linked list
LINKED LISTS.
Using the My EBSCOhost Folder Tutorial support.ebsco.com.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
Chapter 16: Linked Lists.
Linked List ADT used to store information in a list
C++ Programming:. Program Design Including
Linked List :: Basic Concepts
CSCI-255 LinkedList.
Review Deleting an Element from a Linked List Deletion involves:
UNIT-3 LINKED LIST.
Linked lists.
Chapter 4 Unordered List.
Linked List Functions.
Linked Lists.
Linked lists.
Feed Order System Manual
CMPT 225 Lecture 5 – linked list.
Presentation transcript:

C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists (part 3)

C++ Programming: Program Design Including Data Structures, Fourth Edition2 Programming Example: Video Store 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 function

C++ Programming: Program Design Including Data Structures, Fourth Edition3 Programming Example: Video Store (continued) The program should enable the following: −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

C++ Programming: Program Design Including Data Structures, Fourth Edition4 Programming Example: Video Store (continued) Two major components of the video store: −Videos −Customer Maintain the following lists: −A list of all videos in the store −A list of all the store’s customers −Lists of the videos currently rented by the customers

C++ Programming: Program Design Including Data Structures, Fourth Edition5 Part 1: Video Component Video Object 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 the store

C++ Programming: Program Design Including Data Structures, Fourth Edition6 Part 1: Video Component Video List This program requires us to: −Maintain a list of all videos in the store −Be able to add a new video to our list Use a linked list to create a list of videos:

C++ Programming: Program Design Including Data Structures, Fourth Edition9 Part 2: Customer Component Customer Object Primary characteristics of a customer: −First name −Last name −Account number −List of rented videos

C++ Programming: Program Design Including Data Structures, Fourth Edition10 Part 2: Customer Component Customer Object (continued) Basic operations on personType : −Print the name −Set the name −Show the first name −Show the last name

C++ Programming: Program Design Including Data Structures, Fourth Edition11 Part 2: Customer Component Customer Object (continued) Basic operations on an object of the type customerType are: −Print name, account #, and list of rentals −Set the name and account number −Rent a video (i.e., add video to the list) −Return a video (i.e., delete video from the list) −Show the account number

C++ Programming: Program Design Including Data Structures, Fourth Edition12 Part 2: Customer Component Main Program The data in the input file is in the form: video title (that is, the name of the movie) movie star1 movie star2 movie producer movie director movie production co. number of copies.

C++ Programming: Program Design Including Data Structures, Fourth Edition13 Part 2: Customer Component Main Program (continued) Open the input file −Exit if not found createVideoList : create the list of videos displayMenu : show the menu While not done −Perform various tasks

C++ Programming: Program Design Including Data Structures, Fourth Edition14 Part 2: Customer Component createVideoList Read data and store in a video object Insert video in list Repeat steps 1 and 2 for each video in file

C++ Programming: Program Design Including Data Structures, Fourth Edition15 Part 2: Customer Component displayMenu Select one of the following: −Check if the store carries a particular video −Check out a video −Check in a video −Check whether a particular video is in stock −Print the titles of all videos −Print a list of all videos −Exit

C++ Programming: Program Design Including Data Structures, Fourth Edition16 Summary A linked list is a list of items (nodes) −Order of the nodes is determined by the address, called a link, stored in each node The pointer to a linked list is called head or first A linked list is a dynamic data structure The list length is the number of nodes

C++ Programming: Program Design Including Data Structures, Fourth Edition17 Summary (continued) Insertion and deletion does not require data movement −Only the pointers are adjusted A (single) linked list is traversed in only one direction Search of a linked list is sequential The head pointer is fixed on first node Traverse: use a pointer other than head

C++ Programming: Program Design Including Data Structures, Fourth Edition18 Summary (continued) Doubly linked list −Every node has two links: next and previous −Can be traversed in either direction −Item insertion and deletion require the adjustment of two pointers in a node A linked list in which the last node points to the first node is called a circular linked list