Question: Here is the provided WordLadderGame.java file: 1 import java.util.List; 2 3 /** 4 * WordLadderGame.java Defines an interface for games that construct word 5 *


Here is the provided WordLadderGame.java file:
1 import java.util.List; 2 3 /** 4 * WordLadderGame.java Defines an interface for games that construct word 5 * ladders. See https://en.wikipedia.org/wiki/Word_ladder for a definition and 6 * history. 7 * 8 * Word ladders are constructed in the context of some predefined list of valid 9 * words. We will refer to this word list as the lexicon. An implementing class 10 * of this interface must provide a way to explicitly set the lexicon. This will 11 * typically be done in the constructor. 12 * 13 * For the purposes of this interface and all implementing classes, a string is 14 * a word if and only if it appears in the current lexicon. In the documentation 15 * of each interface method, the use of 'string' means that the referenced 16 * string does not have to be a word, while the use of 'word' implies that the 17 * referenced string must be a word. 18 * 19 */ 20 public interface WordLadderGame { 21 22 /** 23 * Returns the Hamming distance between two strings, str1 and str2. The 24 * Hamming distance between two strings of equal length is defined as the 25 * number of positions at which the corresponding symbols are different. The 26 * Hamming distance is undefined if the strings have different length, and 27 * this method returns -1 in that case. See the following link for 28 * reference: https://en.wikipedia.org/wiki/Hamming_distance 29 * 30 * @param str1 the first string 31 * @param str2 the second string 32 * @return the Hamming distance between str1 and str2 if they are the 33 * same length, -1 otherwise 34 */ 35 int getHammingDistance(String str1, String str2); 36 37 38 /** 39 * Returns a word ladder from start to end. If multiple word ladders exist, 40 * no guarantee is made regarding which one is returned. If no word ladder exists, 41 * this method returns an empty list. 42 * 43 * Depth-first search with backtracking must be used in all implementing classes. 44 * 45 * @param start the starting word 46 * @param end the ending word 47 * @return a word ladder from start to end 48 */ 49 List
Doublets.java file:
1 import java.io.BufferedReader; 2 import java.io.InputStream; 3 import java.io.InputStreamReader; 4 5 import java.util.Arrays; 6 import java.util.ArrayDeque; 7 import java.util.ArrayList; 8 import java.util.Deque; 9 import java.util.LinkedList; 10 import java.util.List; 11 import java.util.Scanner; 12 import java.util.TreeSet; 13 14 /** 15 * Doublets.java 16 * Provides an implementation of the WordLadderGame interface. The lexicon 17 * is stored as a TreeSet of Strings. 18 * 19 */ 20 public class Doublets implements WordLadderGame { 21 22 //////////////////////////////////////////// 23 // DON'T CHANGE THE FOLLOWING TWO FIELDS. // 24 //////////////////////////////////////////// 25 26 // A word ladder with no words. Used as the return value for the ladder methods 27 // below when no ladder exists. 28 List
The focus of the assignment is to implement a word connection game that has been played in one variation or another for at least 130 years. The object of the game is to transform a start word into an end word of the same length by a sequence of steps, each of which consists ofA a one-letter change to the current word that results in another legal word. Charles Lutwidge Dodsgon (Lewis Carroll) invented this game and called it "Doublets.It's now more commonly known as "Word Lad ders." Consider the following examples clash, flash, fiask, fiack, flock, clock, crock, crook, croon, crown, clowm cat, can, con, cog, dog cat, bat, eat, fat, gat, hat Each is a valid word ladder from the start word to the end word since the start and end words are the same length and each word in between is exactly one letter different from the previous word. The game is usually played so that each player tries to find the shortest word ladder between two words. The shortest ladder would, of course, depend on the lericon, or list of words, being used for the game. Using the SOWPODS word list (see Provided Resources), word ladders with minimum length for the start-end pairs above would be: clash, class, claus, clows, clowm cat, cot, dot, dog cat, hat Requirements The interface WordLadderGame defines several methods associated with the generation of word ladders. The class Doublets provides an implementation of this interface. You must provide a correct implemn
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
