Question: please do the TODO is the test import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; import java.util.stream.Collectors; class Word { private String w;
please do the "TODO" is the test import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; import java.util.stream.Collectors; class Word { private String w; Word (String w) { this.w = w; } /** * this functionally reduces our hash structure (in our case, HashSet) to a list (due to hashing at the same spot) * after your tests are created, modify this hash function to something of your choice * see how much you can improve your timing :) * (YOU MAY NOT USE BUILT-IN hashCode) */ // TODO after testing public int hashCode () { return 7; } } class Words { static String filename = "commonwords.txt"; // from http://www.mieliestronk.com/corncob_lowercase.txt static List slist; static List wlist; static { try { // note that objects in our slist will have the default hashCode; whereas wlist is a list of objects // from our Word class that has our own hashCode method implemented slist = Files.readAllLines(Paths.get(filename), StandardCharsets.UTF_8); wlist = slist.stream().map(Word::new).collect(Collectors.toList()); } catch (IOException e) { throw new Error(); } } } ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import org.junit.jupiter.api.Test; import java.time.Duration; import java.time.Instant; import java.util.HashSet; import java.util.List; class WordsTest { // write your own tests timing how long it takes to build a hashset with a Listof String and then a Listof Word // refer to Lab 3 tests if you do not remember how to time tests using methods of the Instant & Duration class //this Duration class are not completed Duration time (Random r, int size, int bound) { Instant start = Instant.now(); for (int i=0; i<100; i++) { } for (int i=0; i @Test void timeW () { // TODO } }
_________________________________________________________________________________________________________________________________________________________________________
and here is some thing in "commonwords.txt"
aardvark aardwolf aaron aback abacus abaft abalone abandon abandoned abandonment abandons abase abased abasement abash abashed abate abated abatement abates abattoir abattoirs
Step by Step Solution
There are 3 Steps involved in it
The question is incomplete as it doesnt provide ... View full answer
Get step-by-step solutions from verified subject matter experts
