SUNY Geneseo Department of Computer Science


List Algorithms

{Date}

CSci 141, Spring 2004
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Misc

Exam 2 will be next Thursday (April 1)

Practice Exam on Web

Questions?

No exceptions on test

Comments are good even for face-to-face grading

List algorithms for test can be in terms of list messages

Inductions about lists are usually on length

Beware of blank lines at start of treasure hunt files

Proofs that hunts are correct

Example List Algorithms

Mini-Assignment:

    // In some subclass of List...
    public void delete( Object x ) {
        if ( ! this.isEmpty() ) {
            if ( this.getFirst().equals( x ) ) {
                this.removeItem();
                this.delete( x );
            }
        }
        else {
            this.getRest().delete( x );
        }
    }
    // Postcondition: List contains no items
    // equal to x.

List Subclasses

Look at how removeItem works

Look at how addItem works (end of section 11.4)

[addItem "Wants" to Change "this"]

 

Read Section 11.5.1


Next Lecture