Question: Assume the KWLinkedList class which is similar to java build - in class is given to you ( as discussed in the class, and the
Assume the KWLinkedList class which is similar to java buildin class is given to you as discussed in the class, and the complete class is uploaded on the blackboard do the following with the help of ListIterator or without ListIterator. It is also up to you in required member methods below to call any other method within the class or not.
A Write a method called removeAll within the class that has one parameter item of type E that removes all the elements equal to item in the list. The method head is
public void removeAllE item
B Write a method called addOnce within the class that has one parameter item of type E which adds item to the end of the list if item does not exist in the list. The method head is
public void addOnceE item
C Write a method called removeSecond within the class that has one parameter item of type E that removes the second element in the list equals to item if exists. The method head is
public void removeSecondE item
D Write a method called compareListsHalfs within the KWLinkedList class that has one parameter list of type KWLinkedList. The method returns true if all the elements in the first half of list starting from the head are greater than all the elements in the second half of the this list, otherwise, it returns false. You need to ensure first that the two lists list and this are having the same size and have even number of elements. The method head is
public boolean compareListsHalfsKWLinkedList list
Example:
head
list:
this:
head
The return value is false
Example:
head
list:
this:
head
The return value is true
E Write a class called App that contains the main method, the main method contains some operations performed on some constructed lists you may create two objects l and l from the class KWLinkedList and among these operations are the four stated above. Show the output of the abovementioned methods when they are performed.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
