CS 112 In-Class Assignment
Final Review I
Get ready for the Final:
- For the following linked list class
LinkedListNode.java, create the
following methods:
- object nextToLast(LinkedListNode list) Returns the next-to-last
element in the list. Throw an IllegalArgument exception (not a
checked exception, don't need a 'throws' declaration in method
header)
- void doubleElems(LinkedListNode list). If we pass in a list that
contains A B C D, that list should be transformed into A A B B C C D
D
- Extra challenge: Write a recursive version of doubleElems
- void removeClumps(LinkedListNode list). Remove all adjacent
equal elements. So, if the list was originally A B C B B A A A B,
it should be transformed into A B C B A B