Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There is no starter file. Use the same inputs you used for the Jumbles Project and the expeced output is identical Lab#9 is a re-make

There is no starter file. Use the same inputs you used for the Jumbles Project and the expeced output is identical

Lab#9 is a re-make of the Jumbles project.

Since you know what a TreeSet is you should use it to store your dictionary and jumbles files. No need to call Collections.sort() after the loads.

Your answer key data strucure however must be a HashMap or TreeSet.

Performance for a TreeMap vs. HashMap will be almost identical for inputs of the size we are using.

Actual runtime speed will be very fast. Should be at most around one second even on an older slower laptop.

Output for Jumbles Project:

java Project4 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 

Original Jumbles Project:

import java.io.*; import java.util.*;

public class Project8 { //List for Collecting permutations of word static HashSet perms; //This method calculates the permutations of the string using recursion and stores in the above list. static void genPerms(char str[], int ind){ if(ind==str.length - 1){ perms.add(String.valueOf(str)); return; } for(int i=ind;i hs = new HashSet<>(); while((word = f1.readLine())!=null){ hs.add(word); } //Reading the words String jumbles = args[1]; BufferedReader f2 = new BufferedReader(new FileReader(new File(jumbles))); //List for storing final answer ArrayList fans = new ArrayList<>(); //Iterating through all the jumble words while((word = f2.readLine())!=null){ //finding permutations perms = new HashSet<>(); genPerms(word.toCharArray(),0); String ans = word; //Storing perms in a List ArrayList hor = new ArrayList<>(); for(String x : perms){ if(hs.contains(x)){ hor.add(x); } } //Sorting the list Collections.sort(hor); //Calculating the answer for(String x : hor){ ans = ans+" "+x; } fans.add(ans); } //Sorting the answer vertically Collections.sort(fans); for(String x : fans){ System.out.println(x); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions