Question: The assignment is to upload a dictionary and a jumbled set of words. You store them both in arrays, and then you sort them both

The assignment is to upload a dictionary and a jumbled set of words. You store them both in arrays, and then you sort them both alphabetically and canonically to find the match then output the dictionary word. The output is supposed to be the unmodified jumbled word in alphabetical order, then the dictionary corresponding words in alphabetical order.

We cannot use the hashmap or table etc. I have the code done, but my problem is that I'm missing the word "act" and I cannot see why.

I attached images of everything..the first page is the sample dictionary then the sample jumbled words list then the code and finally what it outputs.

SAMPLE DICTIONARY SAMPLE JUMBLED LIST act atc cat otsp tac gdo dog atr god arpt post grof pots sylogs stop spot tops opts rat tar art trap tarp part flog golf frog gorp glossy

The output I get is Below There should be an "act" in the second line.

arpt tarp part trap

atc cat tac

atr rat art tar

gdo god dog

grof frog

otsp opts post pots spot stop tops

sylogs glossy

The assignment is to upload a dictionary and a jumbled set ofwords. You store them both in arrays, and then you sort them

6 import java.util. 7 import java.io. 9 public class Jumbles public static void main(String[] args) throws Exception 12 14 16 if (args.length > 2) 1 System.out.println("Wrong file"); System.exit(0); BufferedReader dFile new BufferedReader(new FileReader(args [0])); BufferedReader jFile - new BufferedReader(new FileReader(args [1])); ArrayList dWords new ArrayList); ArrayList dCanons new ArrayList); ArrayList pairsnew ArrayList(); ArrayList jCanons new ArrayList); while (dFile. ready ()) 17 20 21 23 24 25 26 27 28 29 30 1 String dword dFile.readLine(); pairs.add (canonicalForm(dWord) dWord); dFile.close(); Collections.sort(pairs); for (String splitD: pairs) s String [] copy splitD.split("Is") dCanons.add (copy [0]); dwords.add(copy L1]); 32 while (jFile.ready )) 34 35 36 s String jWord-jFile.readLine); j Canons.add (jWord +""+ canonicalForm(jWord)); 38 39 40 41 42 43 jFile.close); Collections.sort (jCanons); for (String splitJ: jCanons) s ArrayList print -new ArrayList(); String [] jWordC splitJ.split(" "); System.out.print(jWordC [0]); int index Collections.binarySearch(dCanons, jWordC[1]); int i- index-1; if (index

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!