Lists Chapter 8 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.

Slides:



Advertisements
Similar presentations
Lists Chapter 4 Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights reserved X.
Advertisements

Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
A Bag Implementation that Links Data Chapter 3 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Queues and Priority Queues
Chapter 13 Queues and Priority Queues CS Data Structures Mehmet H Gunes Modified from authors’ slides.
CMPT 225 Abstract Data Types.
CS Data Structures Chapter 8 Lists Mehmet H Gunes
Lists Chapter 4. 2 Chapter Contents Specifications for the ADT List Redefining the Specifications Using the ADT List Using a List Is Like Using a Vending.
List Implementations That Use Arrays Chapter 5 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights reserved X Announcements.
List Implementations That Use Arrays Chapter 5. 2 Chapter Contents Using a Fixed-Size Array to Implement the ADT List An Analogy The Java Implementation.
Sorted Lists and Their Implementations Chapter 12 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 3 Array-Based Implementations CS Data Structures Mehmet H Gunes Modified from authors’ slides.
© 2006 Pearson Addison-Wesley. All rights reserved 4-1 Chapter 4 Data Abstraction: The Walls.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Stacks Chapter 6 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Data Abstraction: The Walls
Data Abstraction and Problem Solving with C++ Walls and Mirrors, Third Edition, Frank M. Carrano and Janet J. Prichard ©2002 Addison Wesley CHAPTER 3 Data.
Queues and Priority Queues
Implementations of the ADT Stack Chapter 7 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 6 Stacks CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Bags Chapter 1 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Trees Chapter 15 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Recursion as a Problem- Solving Technique Chapter 5 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Tree Implementations Chapter 16 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Lists Chapter 4. 2 Chapter Contents Specifications for the ADT List Redefining the Specifications Using the ADT List Java Class Library: The Interface.
Lists Chapter 4 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
Lists Chapter 4. 2 Chapter Contents Specifications for the ADT List Redefining the Specifications Using the ADT List Using a List Is Like Using a Vending.
Recursion as a Problem- Solving Technique Chapter 5 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Heaps Chapter 17 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Iterators (short version) Chapter 15 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem.
Chapter 1 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
C++ Classes C++ Interlude 1 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Graphs. Contents Terminology Graphs as ADTs Applications of Graphs.
Array-Based Implementations Chapter 3 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Lists and Sorted Lists: various implementations Slides by Nadia Al-Ghreimil adopted from Steve Armstrong LeTourneau University Longview, TX  2007, 
Queues and Priority Queue Implementations Chapter 14 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
1 CS162: Introduction to Computer Science II Abstract Data Types.
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem.
Chapter 4 Link Based Implementations
Link Based Implementations
CS Data Structures Chapter 8 Lists Mehmet H Gunes
Lists Chapter 4.
A Bag Implementation that Links Data
Chapter 16 Tree Implementations
Chapter 13 Queues and Priority Queues
C++ Classes C++ Interlude 1
Implementations of the ADT Stack
Stacks Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 4 Link Based Implementations
Chapter 12 Sorted Lists and their Implementations
Copyright ©2012 by Pearson Education, Inc. All rights reserved
List Implementations Chapter 9
CS Data Structures Chapter 17 Heaps Mehmet H Gunes
List Implementations Chapter 9.
Stacks Chapter 6 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Sorted Lists and Their Implementations
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Array-Based Implementations
Lists Chapter 8.
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Queues and Priority Queue Implementations
Recitation 2 CS0445 Data Structures
Copyright ©2012 by Pearson Education, Inc. All rights reserved
© 2016 Pearson Education, Ltd. All rights reserved.
A List Implementation that Uses An Array
© 2016 Pearson Education, Ltd. All rights reserved.
Presentation transcript:

Lists Chapter 8 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Contents Specifying the ADT List Using the List Operations An Interface Template for the ADT List Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Specifying the ADT List You reference list items by their position FIGURE 8-1 A grocery list Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

ADT List Operations Test whether a list is empty. Get number of entries on a list. Insert entry at given position on list. Remove entry at given position from list. Remove all entries from list. Look at (get) entry at given position on list. Replace (set) entry at given position on list. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

FIGURE 8-2 UML diagram for the ADT list ADT List Operations FIGURE 8-2 UML diagram for the ADT list Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Abstract Data Type: LIST Data : A finite number of objects Not necessarily distinct Having the same data type Ordered by their positions determined by client. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Abstract Data Type: LIST Operations isEmpty() getLength() insert(newPosition, newEntry) remove(position) clear() getEntry(position) setEntry(position, newEntry) Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Axioms for the ADT List (new List()).isEmpty() = true (new List()).getLength() = 0 aList.getLength()=(aList.insert(i, x)).getLength() - 1 aList.getLength()=(aList.remove(i)).getLength() + 1 (aList.insert(i, item)).isEmpty() = false (new List()).remove(i) = false (aList.insert(i, x)).remove(i) = aList Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Axioms for the ADT List (new List()).getEntry(i) = error (aList.insert(i, x)).getEntry(i) = x aList.getEntry(i) = (aList.insert(i, x)).getEntry(i + 1) aList.getEntry(i + 1) = (aList.remove(i)).getEntry(i) (new List()).setEntry(i, x) = error (aList.setEntry(i, x)).getEntry(i) = x Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Using the List Operations Displaying the items on a list independent of the implementation Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Using the List Operations Replacing an item. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Using the List Operations Pseudocode statements place names in an alphabetical list View Interface Template for the ADT List, Listing 8-1 .htm code listing files must be in the same folder as the .ppt files for these links to work Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

End Chapter 8 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013