Instructor Notes

Extending the List Class Lab

Supplemental Material for Baldwin and Scragg, Algorithms and Data Structures: The Science of Computing; Charles River Media, 2004 (Now published by Cengage Learning)

Site Index


This lab expects somewhat more sophistication of students than earlier labs for Algorithms and Data Structures: The Science of Computing. Some of the problems students have to solve are more complex, students need to create correctness proofs and performance analyses as well as algorithms and code, and the performance analyses must be phrased as asymptotic times, not concrete operation counts. These factors make the lab both algorithmically challenging and time-consuming.

Algorithmic Issues

Algorithms and Data Structures: The Science of Computing defines a list as a recursive structure, which makes recursion a natural control structure for list algorithms. We thus expect most students to write recursive algorithms to solve the problems in this lab. However, students who have read chapters 8 and 9 of the text will be prepared to design and analyze iterative algorithms if they wish. Instructors who specifically wish to exercise recursion rather than iteration, or vice versa, in this lab should make that requirement clear to students at the start of the lab.

When solved recursively, the problems in this lab expose students to several things that have not been prominent earlier in Algorithms and Data Structures: The Science of Computing. This exposure broadens students’ ability to design and analyze recursive algorithms, but instructors should be prepared for questions arising from it, and should be aware of it as they select exercises to do. For example…

Time Requirements

Because each exercise involves designing and coding an algorithm, writing a correctness proof, and deriving an asymptotic execution time, this lab is time-consuming both for students and for whoever grades the solutions.

Few instructors will assign all the exercises in a single lab session. Instead, most instructors will probably pick a subset of the exercises for their students to do. Depending on the duration of the lab sessions, and the sophistication of the students, subsets containing between two and four of the exercises are reasonable.

The Equality Testing Problem

The message that tests lists for equality is almost the equals message that every Java class should handle. The only difference is that Java’s equals must accept any object as its parameter, whereas the one in this lab only has to accept a List. We specified our message in this way so that students would not have to know how to discover an object’s class in order to solve the exercise. For students who already know how to do this, however, modifying the exercise to write a fully Java-compliant equals method provides good experience writing code to a robust, real-world, specification.


Copyright © 2004 Charles River Media. All rights reserved.

Revised Aug. 9, 2005 by Doug Baldwin

Site Index