ICS 211 Homework 9

Recursive Linked List Methods

0. Goals and Overview

The goal of this assignment is to practice writing recursive methods/functions that operato on the recursive linked list data structure. For this assignment you will modify the LinkedListRecursive class, which is based on the LinkedList class we have already studied, but only has the single instance variable head. Because there is only one instance variable, there are no useful class invariants relating different instance variables. This makes the code simpler than it would be otherwise, but at times less efficient, e.g. the size method takes linear time rather than constant time.

Linked list here refers to both the LinkedListRecursive class, and the sequence of linked nodes beginning at the head instance variable. All the methods required by this assignment are public methods of the LinkedListRecursive class and operate on the sequence of linked nodes beginning at head. Your methods must also work correctly when head == null.

1. Standard Methods (50%)

Stubs have been provided for the five standard methods: size, remove, toString, and the one- and two-parameter add methods. Each of these must be implemented recursively, many of them by calling a recursive helper method that you must define and implement.

2. Special Methods (50%)

Turning in the Assignment

Once you are done, find your src directory and navigate to edu.ics211.h09, then turn the .java files into Laulima directly, without zipping or archiving.

You should also turn in your unit test code. The TA may refer to it if they have questions while grading your code, but your grade for this assignment does not depend on the quality of your unit test.