write, in Java, programs to investigate word ladders composed of five letter words. A word ladder...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
write, in Java, programs to investigate word ladders composed of five letter words. A word ladder is a sequence of words, each member of the sequence differing from its predecessor in exactly one position. For example, the following ladder, of length 6, 'transforms the word flour into the word bread. flour →floor →flood blood-brood broad → bread A dictionary file words5.txt will be provided, which contains a set of nearly 2000 five-letter words that should be used to construct ladders. Your programs should do the minimum amount of work necessary in each case. Program 1. The first program should read in a dictionary file, together with two more five letter words, i.e. the program should take 3 command-line arguments: 1. a dictionary file 2. a start word; 3. an end word. The program should produce on the standard output channel the length of the shortest path and a path/ladder of shortest length that transforms the start word into the end word, or should report that no ladder is possible. The final line of output should report the execution time of the program in seconds. (The code to generate this output is included in the skeleton programs provided. Note that it represents elapsed time, so may not be an accurate reflection of actual running time depending on other processes that may be executing on the computer.) Program 2. The second program considers a weighted version of the word ladder problem where the weight of a transformation (i.e. edge of the corresponding graph) is the absolute difference in the positions of the alphabet of the non-matching letter. For example, the weight of the edge between angel and anger equals the position of minus the position of / which is 6. This second program should implement Dijkstra's algorithm for finding the shortest paths. Similarly to the first case, the program should read in a dictionary file, together with two more five letter words the program and report on the standard output channel the minimum distance between the words together with a corresponding path, or should report that no ladder is possible. As for the first program, the final line of output should report the execution time of the program in seconds. Clarifications. The dictionary file (words5.txt) contains only words of 5 letters, all in lower-case, one word per line; No data validation is needed: you can assume that input to the first program is provided in the appropriate format, with all words in lower case; You can assume also that each word that is input is actually present in the given word file; a graph representation of the dictionary is the key to an efficient solution; Graphs should be represented using adjacency lists and the program from the warm up labo- ratory exercise provides a very good basis for you programs. write, in Java, programs to investigate word ladders composed of five letter words. A word ladder is a sequence of words, each member of the sequence differing from its predecessor in exactly one position. For example, the following ladder, of length 6, 'transforms the word flour into the word bread. flour →floor →flood blood-brood broad → bread A dictionary file words5.txt will be provided, which contains a set of nearly 2000 five-letter words that should be used to construct ladders. Your programs should do the minimum amount of work necessary in each case. Program 1. The first program should read in a dictionary file, together with two more five letter words, i.e. the program should take 3 command-line arguments: 1. a dictionary file 2. a start word; 3. an end word. The program should produce on the standard output channel the length of the shortest path and a path/ladder of shortest length that transforms the start word into the end word, or should report that no ladder is possible. The final line of output should report the execution time of the program in seconds. (The code to generate this output is included in the skeleton programs provided. Note that it represents elapsed time, so may not be an accurate reflection of actual running time depending on other processes that may be executing on the computer.) Program 2. The second program considers a weighted version of the word ladder problem where the weight of a transformation (i.e. edge of the corresponding graph) is the absolute difference in the positions of the alphabet of the non-matching letter. For example, the weight of the edge between angel and anger equals the position of minus the position of / which is 6. This second program should implement Dijkstra's algorithm for finding the shortest paths. Similarly to the first case, the program should read in a dictionary file, together with two more five letter words the program and report on the standard output channel the minimum distance between the words together with a corresponding path, or should report that no ladder is possible. As for the first program, the final line of output should report the execution time of the program in seconds. Clarifications. The dictionary file (words5.txt) contains only words of 5 letters, all in lower-case, one word per line; No data validation is needed: you can assume that input to the first program is provided in the appropriate format, with all words in lower case; You can assume also that each word that is input is actually present in the given word file; a graph representation of the dictionary is the key to an efficient solution; Graphs should be represented using adjacency lists and the program from the warm up labo- ratory exercise provides a very good basis for you programs.
Expert Answer:
Answer rating: 100% (QA)
Program 1 Java import javaio Buffered Reader import javaioFileReader import javaioIOException import javautilList public class Program1 public static ... View the full answer
Related Book For
Discrete and Combinatorial Mathematics An Applied Introduction
ISBN: 978-0201726343
5th edition
Authors: Ralph P. Grimaldi
Posted Date:
Students also viewed these programming questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
QUIZ... Let D be a poset and let f : D D be a monotone function. (i) Give the definition of the least pre-fixed point, fix (f), of f. Show that fix (f) is a fixed point of f. [5 marks] (ii) Show that...
-
Under a plan of complete liquidation, Coast Corporation distributes land with a $300,000 adjusted basis and a $400,000 FMV to William, a 25% shareholder. William has a $200,000 basis in his Coast...
-
Identify a product that is not a market leader and develop a marketing plan for which the framing effect could be used to encourage consumers to reverse their preferences. Be sure to include relevant...
-
Find the most general antiderivative or indefinite integral. You may need to try a solution and then adjust your guess. Check your answers by differentiation. - cos 6t dt 2 1-
-
Plaintiff purchased stain and paint from defendant that, upon application, presented significant issues: discoloration and cracking. These issues became apparent 30 days after receipt of the...
-
Value engineering, target pricing, and locked-in costs. Pacific Dcor, Inc., designs, manufactures, and sells contemporary wood furniture. Ling Li is a furniture designer for Pacific. Li has spent...
-
Westeros, Inc. receives scabbards (sheath for a sword) from two different suppliers. 70 percent of its scabbards come from Knights Watch, LLC, while 30 percent come from Crow, Inc. Records indicate...
-
Coca Cola (KO) price is $61/share. The company is expected to pay dividend of $1.7/share next year. (In reality, dividends are paid quarterly. In this question we will assume for simplicity that all...
-
3. I/O a. How are major and minor device numbers used? Explain. b. What are two differences between block devices and character devices? c. What advantages does memory-mapped I/O have over I/O ports?...
-
SJH Consulting is a successful firm founded 10 years ago by three experienced consultants who left a major consulting company to set up their own practice. They have slowly expanded, mainly using...
-
Task Details: Invigilated exam of 60 minutes duration. A non-programmable calculator will be required. No other materials are permitted in the exam. The exam will be based on short theory and...
-
2 3 On December 1, Jasmin Ernst organized Ernst Consulting. On December 3, the owner contributed $84,920 in assets to launch the business. On December 31, the company's records show the following...
-
please help with this recursion problem. Recursion.java public class Recursion { /** * Returns the value of x * y, computed via recursive addition. * x is added y times. Both x and y are...
-
White Orion is a manufacturer of prams (baby/child carriages) and has been in business for over 100 years. They are a family run firm and are proud of their traditional products, which have been used...
-
Suppose that f'(0) = -1 = f(0). Then f(t3 + 2t2 t - 2) +3 lim t+1 t2 1 () -3 (b) -2 (c) -1 (d) impossible to determine without additional information (e) none of these
-
A number of years ago the United Food and Commercial Workers Union organized 800 workers of the 1035 employees at one of the Wilson Brothers food operations in Toronto, Ontario. The employees include...
-
Complete the calculations in Example 17.17 in order to obtain the two 5 5 Latin squares L3 and L4. Rewrite each Latin square L1, for 1 < i < 4, in standard form.
-
Determine whether or not each of the following sets of numbers is a ring under ordinary addition and multiplication. a) R = the set of positive integers and zero b) R = {kn|n Z, k a fixed positive...
-
Shay rolls a fair die until she gets a 6. If the random variable Y counts the number of times Shay rolls the die until she gets her first 6, determine (a) the probability distribution for F; (b)...
-
Using a cover letter you have written, review your online presence. What key words do you see in your social networking profiles? What job experience, education, and skills are highlighted? How can...
-
All-Weather Inc. invited applications for the position of sales representative. This person will be based in Nebraska and will be responsible for sales of All-Weathers vinyl windows in local markets,...
-
Identify and correct the errors in the following passages. a. Company's are finding it to their advantage to cultivate their suppliers. Partnerships among a company and it's suppliers can yield hefty...
Study smarter with the SolutionInn App