Recursive Linked Lists, due Tuesday, 9/3
Download this file, and complete the methods using recursion. You should make your own main method to test your solutions. Try weird inputs, like running sum() on an empty list, or using an index too large for the list; your program should handle those correctly.
The methods to be finished are:
- add2front: self explanatory. There's no recursion to be done here.
- printInOrder: Print out the elements of the list, in the order they appear in the list, from first node to last node. You'll need a helper method with a different signature to do this (I have started it for you).
- printInReverseOrder: Print out the elements of the list, from last to first. Again, you'll need a helper method.
- sum: Return (not print), the sum of the elements of the list. Helper needed.
- get(int i): Return (not print), the element in the i-th link. Helper needed.
- remove(int i): Excise the i-th link from the list. Helper needed.
If you don't remember recursion well, this might take you a while. Please don't wait to start until Monday night.
This should be submitted using the procedure explained on the Resources page as "recursion." It is not necessary to submit your class with a main method, as I'll use my own for grading; it won't break anything to include it, though.