Computer Science 245: Data Structures and Algorithms

Homework 3: Lists (due 2/18/2015)


For your third homework assignment, you will extedning an existsing simple linked list class to add be adding some methods to a simple linked list class. The provided list class uses a dummy element. There are 3 methods that you will need to add:

reverse()

Reverses the list. Note that the dummy element needs to remain at the beginning of the list after reversal!

void remove(Object o)

Removes the first occurance of element o in the list. If o does not exists in the list, then this method does nothing. Be sure to handle all cases correctly - removing an element a the beginning, end, and middle of the list!

String toString()

Creates a string representation of the list. The string should be a Left parenthesis, followed by by concatenating the result of toString() called on each element of the list (separated by commas), fooled by a right parenthesis. Examples:

Provided files

Submission

Please place your new version of LinkedList.java, along with the (unchanged!) ListNode.java into subversion under:

https://www.cs.usfca.edu/svn/<username>/cs245/Homework3/