Copyright ©2012 by Pearson Education, Inc. All rights reserved

Slides:



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

Lists Chapter 4 Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights reserved X.
The Efficiency of Algorithms Chapter 4 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
A Bag Implementation that Links Data Chapter 3 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
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.
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.
Queue, Deque, and Priority Queue Implementations Chapter 11 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Queues, Deques and Priority Queues Chapter 10 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
1 Collection, Iterable, and Iterator Interfaces The Collection Interface and its Hierarchy The Iterable and Iterator Interfaces For-each Loops with Iterable.
Bags Chapter 1 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Data Structures and Abstractions with Java, 4e Frank Carrano
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.
Stack Implementations Chapter 6 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
© 2006 Pearson Addison-Wesley. All rights reserved5 B-1 Chapter 5 (continued) Linked Lists.
A Heap Implementation Chapter 26 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Iterators (short version) Chapter 15 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Array-Based Implementations Chapter 3 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 18 List ADT Animated Version.
Sorted Lists Chapter Chapter Contents Specifications for the ADT Sorted List Using the ADT Sorted List A Linked Implementation The Method add The.
1 The copy constructor in the BankAccounts class. Two alternatives here: /** copy constructor */ public BankAccounts(BankAccounts L){ theAccounts = L.theAccounts.clone();
Lists and Sorted Lists: various implementations Slides by Nadia Al-Ghreimil adopted from Steve Armstrong LeTourneau University Longview, TX  2007, 
1 CS162: Introduction to Computer Science II Abstract Data Types.
An Array-Based Implementation of the ADT List
Comprehensive Introduction to OOP with Java, C. Thomas Wu Stack ADT
Linked Lists Chapter 5 (continued)
CS Data Structures Chapter 8 Lists Mehmet H Gunes
Lists Chapter 4.
Bag Implementations that Use Arrays
A Bag Implementation that Links Data
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Queues, Deques and Priority Queues
Queue, Deque, and Priority Queue Implementations
A Bag Implementation that Links Data
Queue, Deque, and Priority Queue Implementations
Queues, Deques and Priority Queues
Stacks Chapter 5 Adapted from Pearson Education, Inc.
TCSS 143, Autumn 2004 Lecture Notes
Chapter 12 Sorted Lists and their Implementations
Data Type (how to view it)
Hashing as a Dictionary Implementation
List Implementations Chapter 9
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Adapted from Pearson Education, Inc.
List Implementations Chapter 9.
EE 422C Sets.
Array-Based Implementations
List Implementations that Use Arrays
A List Implementation That Links Data
Sorted Lists and Their Implementations
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Array-Based Implementations
A Heap Implementation Chapter 26 Adapted from Pearson Education, Inc.
Linked Lists Chapter 5 (continued)
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Linked Lists Chapter 5 (continued)
Java Generics & Iterators
A List Implementation That Links Data
Copyright ©2012 by Pearson Education, Inc. All rights reserved
List Implementations that Use Arrays
Stack Implementations
© 2016 Pearson Education, Ltd. All rights reserved.
A List Implementation that Uses An Array
A List Implementation that Links Data
© 2016 Pearson Education, Ltd. All rights reserved.
Presentation transcript:

Copyright ©2012 by Pearson Education, Inc. All rights reserved Lists Chapter 12 Copyright ©2012 by Pearson Education, Inc. All rights reserved

Copyright ©2012 by Pearson Education, Inc. All rights reserved Contents Specifications for the ADT List Using the ADT List Java Class Library: The Interface List Java Class Library: The Class ArrayList Copyright ©2012 by Pearson Education, Inc. All rights reserved

Copyright ©2012 by Pearson Education, Inc. All rights reserved Objectives Describe the ADT list Use the ADT list in a Java program Copyright ©2012 by Pearson Education, Inc. All rights reserved

Copyright ©2012 by Pearson Education, Inc. All rights reserved Lists A collection Has order … which may or may not matter Additions may come anywhere in list Figure 12-1 A to-do list Copyright ©2012 by Pearson Education, Inc. All rights reserved

Copyright ©2012 by Pearson Education, Inc. All rights reserved Lists Typical actions with lists Add item at end (although can add anywhere) Remove an item (or all items) Replace an item Look at an item (or all items) Search for an entry Count how many items in the list Check if list is empty Copyright ©2012 by Pearson Education, Inc. All rights reserved

Copyright ©2012 by Pearson Education, Inc. All rights reserved ADT List Data A collection of objects in a specific order and having the same data type The number of objects in the collection Operations add(newEntry) add(newPosition, newEntry) remove(givenPosition) … Copyright ©2012 by Pearson Education, Inc. All rights reserved

Copyright ©2012 by Pearson Education, Inc. All rights reserved ADT List Operations (ctd.) clear() replace(givenPosition, newEntry) getEntry(givenPosition) contains(anEntry) getLength() isEmpty() toArray() Copyright ©2012 by Pearson Education, Inc. All rights reserved

Copyright ©2012 by Pearson Education, Inc. All rights reserved Figure 12-2 The effect of ADT list operations on an initially empty list Copyright ©2012 by Pearson Education, Inc. All rights reserved

List View list interface, Listing 12-1 Using the ADT List Don’t need to know how of implementation Only need to know what it does Consider keeping list of finishers of a running race View client code, Listing 12-2 Output Note: Code listing files must be in same folder as PowerPoint files for links to work Copyright ©2012 by Pearson Education, Inc. All rights reserved

Copyright ©2012 by Pearson Education, Inc. All rights reserved Figure 12-3 A list of numbers that identify runners in the order in which they finished a race Copyright ©2012 by Pearson Education, Inc. All rights reserved

Java Class Library: The Interface List Method headers public T remove(int index) public void clear() public boolean isEmpty() public boolean add(T newEntry) public void add (int index, T newEntry) ... Copyright ©2012 by Pearson Education, Inc. All rights reserved

Java Class Library: The Interface List Method headers (ctd.) public T set(int index, T anEntry) // like replace public T get(int index) // like getEntry public boolean contains (Object anEntry) public int size() // like getLength Copyright ©2012 by Pearson Education, Inc. All rights reserved

Java Class Library: The Interface ArrayList Implementation of ADT list with resizable array Implements java.util.list Constructors available public ArrayList() public ArrayList (int initialCapacity) Copyright ©2012 by Pearson Education, Inc. All rights reserved

Copyright ©2012 by Pearson Education, Inc. All rights reserved End Chapter 12 Copyright ©2012 by Pearson Education, Inc. All rights reserved