CS 136 Tutorials - Spring 2007

Tutorials »

Tutorial 10: List Processing, Generics, and Iteration (July 6)

Today's tutorial covers list processing in Java using the GenList class. We will see the use of generics, and will write methods in both the recursive and iterative style. The topics for today's tutorial come from lecture modules 9 and 10 (see handouts).

You won't be able to do much for this tutorial without the skeleton code. It's available in a zip file or a gzipped tar.

  1. Recursive List Processing
  2. Iterative List Processing
  3. Now rewrite all the methods you just implemented using iteration instead of recursion for the list processing. You shouldn't need any helper methods now. Again, test with FrequencyListTest.

  4. One more method...
  5. Now go back and implement the method we skipped, mostFrequent(int k) First write the method using recursion, then using iteration. Make use of the provided helper method, insert. For a final challenge, rewrite insert to use iteration instead of recursion.

Last modified on Wednesday, 09 January 2019, at 14:31 hours.