CS 12 -- Lab 5

Today's we will do some simple, initial work with linked lists. We're construct simple ones and then try to manipulate them.

See the solution.


Your assignment

You must write a program that does the following:

  1. Accept a line of input from the keyboard as a String. (Use the User.readLine() method.)

  2. Convert the String into a singly linked list of char.

  3. Traverse and output the contents of that list.

  4. Reverse the linked list. This step must be done recursively and in place -- that is, without allocating any new links.

  5. Traverse and output the contents of the now-reversed list.

You should write this program first by creating a instantiable CharLinkNode class. An object of this class will hold single char and a pointer to another link. Then, you should write a static ListReverse class that will contain the rest of your code and use CharLinkNode for building its list.


What you must submit

Once you have written and tested CharLinkNode and ListReverse, you must use the cs12-submit command to turn in your Java code. Submit this assignment as lab-5 when you use the cs12-submit command.


This assignment is due on Thursday, March 25th, at 11:59 pm.

Scott F. Kaplan
Last modified: Sun Nov 5 22:48:52 EST 2000