SUNY Geneseo Department of Computer Science


Introduction to Lists

{Date}

CSci 141, Fall 2004
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Misc

Hand out Lab 7

No office hours tomorrow

Questions?

Reading Summary

Sections 11.1 - 11.3

Introduces lists and list processing

Formal definition of list class

Recursion key to many list algorithms

Operations:

List can be described as series of lists

What's a Data Structure?

Tables filled with data and linked together?

Structure = organized data

Organization of data for...

Other structures

    for i = 0 to 100            <- loop, containing...
        if i is odd             <- conditional, selects...
            print i             <- primitive action
        else
             j = i - 3          <- primitive

Most of these are relevant to organizing data

What Are My Bags of Toys?

They're recursive lists

Some List Algorithms

Return the last element from a list

    // In the List class...
    // Precondition: list is not empty
    Object last()
        if ( ! this.getRest().isEmpty() )
            return this.getRest().last()
        else
            return this.getFirst()

[Structures of Algorithm and Definition of List Correspond]

Next

Implementing and extending the List class

Read Sections 11.4 through 11.5.2


Next Lecture