CP114-Lists lectures - Lists Lists are linear collections like stacks and queues but are more flexible Adding and removing elements in lists are not

CP114-Lists lectures - Lists Lists are linear collections...

This preview shows page 1 - 13 out of 29 pages.

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
Image of page 1

Subscribe to view the full document.

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
Image of page 2
A conceptual view of an ordered list
Image of page 3

Subscribe to view the full document.

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
Image of page 4
A conceptual view of an unordered list
Image of page 5

Subscribe to view the full document.

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
Image of page 6
A conceptual view of an indexed list
Image of page 7

Subscribe to view the full document.

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
Image of page 8
The common operations on a list
Image of page 9

Subscribe to view the full document.

The operation particular to an ordered list
Image of page 10
The operations particular to an unordered list
Image of page 11

Subscribe to view the full document.

The operations particular to an indexed list
Image of page 12
Image of page 13
  • Fall '13
  • sta
  • Array data structure, Elk, The Elements

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes