Wite a method static void reverse listltintegergt l which


As we have discussed in class, section 4.1 of our text develops a List ADT and then offers two different implementations of it in the classes AList and LList.

The ADT is defined in a Java interface file List.java, and both AList and LList implement all the required methods of this interface. As a result, either implementation can be used, and while their internal methods and means of storing data differ, both give identical behavior.

During a recent class meeting, we wrote a class that created either an AList or LList object, used a few methods such as insert and remove, and printed it out. We saw that these features all worked correctly for both AList and LList objects; our code simply called the methods defined in the List interface and they worked.

For this assignment, you will write a new class and create three methods that take one (or two) List objects and perform operations on them using only the public List methods. Here are the three methods to write:

1 Write a method static void swap (List l) which interchanges the current element in the list and the one following it. (First make it work in the normal case; then, if you still have time, make sure it handles special cases, such as: the list is empty; the list has only one element; current is at the end of the list

2 Write a method static void reverse (List l) which reverses the order of items stored in the list. Again, make sure it works for any special cases you can think of.

3 Write a method static List mergeLists (List l1, List l2) which takes two sorted Lists as input, producing a new List containing all the elements of both lists, also sorted. The new list is the return value for the method.

In your test class's main method, write a series of statements to create several AList and/or LList objects (of type ) and put some data into them by calling the List append and/or insert methods. Use the lists you build as parameters to test each of your three methods and show that they work.

Test each of your three methods with a minimum of three different test inputs. Show that your methods work for various test cases such as the examples given above. Make sure your program prints the 'before' and 'after' lists for each of your tests.

Finally, copy the output of your program to a '.txt' or '.doc' file. Don't forget to put your name at the top of the document.

Attachment:- Assignment.rar

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Wite a method static void reverse listltintegergt l which
Reference No:- TGS01603613

Expected delivery within 24 Hours