Question: Jumbles problem The Assignment You do not get a starter file. You must write it completely from scratch. Your program should take two command args:

Jumbles problem

The Assignment

You do not get a starter file. You must write it completely from scratch.

Your program should take two command args: a dictionary file and a jumbles file. For each jumbled word you must find all the matching dictionary words and print them after the jumbled word ion the line.

I will test with the dictionary.txt and jumbles.txt.

Here is a tiny version of each input that you should test with until you are sure your code is correct: tinyDictionary.txt and tinyJumbles.txtand correct output for it them: tinyCorrectOuput.txt.

tinyDictionary.txt

act cat tac dog god post pots stop spot tops opts rat tar art trap tarp part flog golf frog gorp glossy 

tinyJumbles.txt

atc otsp gdo atr arpt grof sylogs 

tinyCorrectOuput.txt.

arpt part tarp trap atc act cat tac atr art rat tar gdo dog god grof frog otsp opts post pots spot stop tops sylogs glossy 

Here is the correct execution command and output from a sample run of your program YOUR OUTPUT MUST MATCH EXACTLY. Notice the list of jumbles words is sorted vertically and the matching dictionary words that come after are sorted left to right.

java Project8 dictionary.txt jumbles.txt addej jaded ahicryrhe hierarchy alvan naval annaab banana baltoc cobalt braney nearby celer creel couph pouch cukklen knuckle dica acid cadi caid dobeny beyond dobol blood dufil fluid dupled puddle eslyep sleepy ettniner renitent ettorp potter genjal jangle gluhc gulch hartox thorax hoybis boyish hucnah haunch iddec diced irrpo prior kutbec bucket lappor poplar lasia alias laurib burial lubly bully meefal female milit limit mopsie impose mycall calmly nekel kneel nokte token noper prone nwae anew wane wean nyegtr gentry perrim primer preko poker pudmy dumpy pypin nippy rebisc scribe rodug gourd rpeoims imposer promise semipro shewo howes whose wardty tawdry warllc yaldde deadly 

A JUMBLES STRATEGY

STEP#1 BUILD THE ANSWER KEY for each dictionary word dWord // i.e dWord = "spot" String dCanon = toCanon( dWord ); // dCanon = " opst" (canonical copy ofthe dictionary word) int index = bsearch( answerKey, dCanon ); // search the answerKey list for a string that .startsWith( dCanon ); if there is such a string in answerKey go to that string and tack on: " " + spot // answerKey.set( index, answerKey.get(index) + " " + dWord ); if there is no such string in the answerKey your search should have returned a negative index to tell you where it belongs convert that negative index like you did in a prev. project insert a new string into the answerKey: opst + " " + spot // answerKey.add(index, dWord + " " + dCanon ); end for each word in dictioanry list YOU NOW HAVE AN ANSWER KEY BUILT. STEP #2 PRINT EACH JUMBLES WORD DOWN THE LEFT SIDE OF THE SCREEN FOLLOWED BY ANY DICTIONARY WORDS THAT MATCH for each jumbled word jWord in the jumbles list // i.e. jWord = "sopt" System.out.print( jWord + " " ); String jCanon = toCanon( jWord ); // jCanon = "opst" (canonical version of the jumbled word) int index = bsearch( answerKey, jCanon ); // search the answerKey list for a string that .startsWith( jCanon ); if there is such a string in answerKey println that string but only print the part of the string after the first word inside the string if there is no such string in the answerKey just do System.out.println(); end for each jWord in the jumbles list YOU MUST WRITE A BSEARCH METHOD you must write a bsearch like you wrote for a recent project you must change one line. Do not test for .equals() Test for .startsWith() i.e. if (answerKey.get(mid).startsWith( canonPrefix ) ) return mid; YOU NEED a toCanon() method that makes a copy of a String but with its letters sorted alphabetically static string toCanon( String s ) { char[] letters = s.toCharArray(); // letters -> [z][e][b][r][a] Arrays.sort( letters ); // letters -> [a][b][e][r][z] return new String( letters ); // "aberz" } 
 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!