List.ppt

60 246 0
List.ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter 8 Lists Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-2 Chapter Objectives • Examine list processing and various ordering techniques • Define a list abstract data type • Demonstrate how a list can be used to solve problems • Examine various list implementations • Compare list implementations Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-3 Lists • Lists are linear collections, like stacks and queues, but are more flexible • Adding and removing elements in lists are not restricted by the collection structure • That is, they don't have to operate on one end or the other • We will examine three types of list collections: – ordered lists – unordered lists – indexed lists Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-4 Ordered Lists • The elements in an ordered list are ordered by some inherent characteristic of the elements – names in alphabetical order – scores in ascending order • Therefore, the elements themselves determine where they are stored in the list Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-5 FIGURE 8.1 A conceptual view of an ordered list Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-6 Unordered Lists • There is an order to the elements in an unordered list, but that order is not based on element characteristics • The user of the list determines the order of the elements • A new element can be put on the front or the rear of the list, or it can be inserted after a particular element already in the list Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-7 FIGURE 8.2 A conceptual view of an unordered list Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-8 Indexed Lists • In an indexed list, elements are referenced by their numeric position in the list • Like an unordered list, there is no inherent relationship among the elements • The user can determine the order • Every time the list changes, the indexes are updated Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-9 FIGURE 8.3 A conceptual view of an indexed list Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-10 List Operations • There are several operations common to all three list types • These include removing elements in various ways and checking the status of the list • The key differences between the list types involve the way elements are added . how a list can be used to solve problems • Examine various list implementations • Compare list implementations Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-3 Lists • Lists. collections: – ordered lists – unordered lists – indexed lists Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-4 Ordered Lists • The elements in an ordered list are ordered by some inherent. an unordered list Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-8 Indexed Lists • In an indexed list, elements are referenced by their numeric position in the list • Like

Ngày đăng: 16/07/2014, 01:00

Mục lục

  • FIGURE 8.1 A conceptual view of an ordered list

  • FIGURE 8.2 A conceptual view of an unordered list

  • FIGURE 8.3 A conceptual view of an indexed list

  • FIGURE 8.4 The common operations on a list

  • FIGURE 8.5 The operation particular to an ordered list

  • FIGURE 8.6 The operations particular to an unordered list

  • FIGURE 8.7 The operations particular to an indexed list

  • FIGURE 8.8 The various list interfaces

  • FIGURE 8.9 Bowling league team names and number of wins

  • FIGURE 8.10 Sample tournament layout for a bowling league tournament

  • FIGURE 8.11 UML description of the Tournament class

  • FIGURE 8.12 UML description of the Josephus program

  • Implementing Lists with Arrays

  • FIGURE 8.13 An array implementation of a list

  • ArrayList - the remove Operation

  • ArrayList - the find Operation

  • ArrayList - the contains Operation

  • ArrayOrderedList - the add Operation

  • Implementing lists with links

  • LinkedList - the remove Operation

Tài liệu cùng người dùng

Tài liệu liên quan