Question: JAVA Data Structures Course: Hint for B) There are 3 Corner Cases; the found node might be at the head of the list; it might
JAVA Data Structures Course:
Hint for B) There are 3 Corner Cases; the found node might be at the head of the list; it might be at the tail of the list; or it might be both the head and tail of the list.
Here is the WordNode class:
-------------------------------------------------------------------------------------------------------------------------
public class WordNode implements Comparable
// Declaring variables
private String word;
private WordNode next;
// Constructor
public WordNode(String word) {
this.word = word;
}
// Getter for word
public String getWord() {
return word;
}
// Getter for next
public WordNode getNext() {
return next;
}
// Setter for next
public void setNext(WordNode next) {
this.next = next;
}
// Implementing unimplemented method compareTo
@Override
public int compareTo(WordNode wN) {
// TODO Auto-generated method stub
return word.compareTo(wN.word);
}
// Equals Method
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
WordNode w=(WordNode)obj;
return word.equals(w);
}
}

The following class implements a linked list, using the WordNode class from the previous problem: public class WordList private WordNode private WordNode head; taili Write the following methods for this class: A) int countLongWords (int length) - Returns the number of words in the list where the word length is greater than length. Throws IllegalArgumentException with an appropriate message if length is negative. (20 points) B) void replicate(string target, int numcopies) - This is like the duplicate and triplicate methods that you've already seen, but the caller specifies how many copies of the node should be made. The method searches the list for the first node whose word is deep-equal to target. If no such node exists, the method just returns. If the node is found, the method makes numCopies new nodes and inserts them into the list immediately after the found node. HINT: there are 3 corner
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
