Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

4 ) Which of the following IPv 6 address is valid?

Answered: 1 week ago