Question: my code java has errors, errors are below code pointed out, pls help homework directions are after code and errors package pa1; import edu.princeton.cs.algs4.In; import

my code java has errors, errors are below code pointed out, pls help homework

directions are after code and errors

package pa1; import edu.princeton.cs.algs4.In; import edu.princeton.cs.algs4.StdOut; import edu.princeton.cs.algs4.ST; import edu.princeton.cs.algs4.SeparateChainingHashST; import edu.princeton.cs.algs4.LinearProbingHashST; import edu.princeton.cs.algs4.SequentialSearchST; import static javax.swing.UIManager.get; public class TestPerf { private STst; public static long LinearProbingHashST(String x[]) { LinearProbingHashST st = new LinearProbingHashST(); long start = System.currentTimeMillis(); for(int i = 0; i < x.length; i++){ String key = x[i]; if (!st.contains(key)) st.put(key, 1); else st.put(key,st.get((key) + 1)); } long finish = System.currentTimeMillis(); return (finish - start); } public TestPerf() { } public TestPerf(String fname) { In in = new In(fname); ST st = new ST(); while (in.hasNextLine()) { String line = in.readLine(); String[] words = line.split("\\s+"); for (int i = 0; i < words.length; i++) { String lcWord = words[i].toLowerCase(); if (st.contains(lcWord)) { st.put(lcWord, st.get(lcWord) + 1); } else { st.put(lcWord, 1); } } } } public int getTotalWords() { int count = 0; for (String key : st.keys()) { count += st.get(key); } return count; } public int getUniqueWords() { return st.size(); } public String getMostUsedWord() { String mostUsedWord = ""; int maxOccurrence = 0; for(String key : st.keys()){ if (st.get(key) > maxOccurrence) { maxOccurrence = st.get(key); mostUsedWord = key; } } return "mostUseWord"; } public int getMaxOccurrence() { int maxOccurrence = 0; for (String key : st.keys()) { if(st.get(key) > maxOccurrence) { maxOccurrence = st.get(key); } } return maxOccurrence; } }

This is what i wrote but it has errors in java

These are the errors it shows:

PS C:\Users\src> javac -d out pa1/TestPerf.java pa1\TestPerf.java:2: error: package edu.princeton.cs.algs4 does not exist import edu.princeton.cs.algs4.In; ^ pa1\TestPerf.java:3: error: package edu.princeton.cs.algs4 does not exist import edu.princeton.cs.algs4.StdOut; ^ pa1\TestPerf.java:4: error: package edu.princeton.cs.algs4 does not exist import edu.princeton.cs.algs4.ST; ^ pa1\TestPerf.java:5: error: package edu.princeton.cs.algs4 does not exist import edu.princeton.cs.algs4.SeparateChainingHashST; ^ pa1\TestPerf.java:6: error: package edu.princeton.cs.algs4 does not exist import edu.princeton.cs.algs4.LinearProbingHashST; ^ pa1\TestPerf.java:7: error: package edu.princeton.cs.algs4 does not exist import edu.princeton.cs.algs4.SequentialSearchST; ^ pa1\TestPerf.java:11: error: cannot find symbol private STst; ^ symbol: class ST location: class TestPerf pa1\TestPerf.java:13: error: cannot find symbol LinearProbingHashST st = new LinearProbingHashST(); ^ symbol: class LinearProbingHashST location: class TestPerf pa1\TestPerf.java:13: error: cannot find symbol LinearProbingHashST st = new LinearProbingHashST(); ^ symbol: class LinearProbingHashST location: class TestPerf pa1\TestPerf.java:31: error: cannot find symbol In in = new In(fname); ^ symbol: class In location: class TestPerf pa1\TestPerf.java:31: error: cannot find symbol In in = new In(fname); ^ symbol: class In location: class TestPerf pa1\TestPerf.java:32: error: cannot find symbol ST st = new ST(); ^ symbol: class ST location: class TestPerf pa1\TestPerf.java:32: error: cannot find symbol ST st = new ST(); ^ symbol: class ST location: class TestPerf 13 errors

Test Hash Table - number of overall keys before deletion (5.0/5.0)

Test Hash Table - number of valid keys after deletion (0.0/5.0)Test Failed: Should be 8 expected:<8> but was:<10> at pa1.tests.TestLinearProbing.test_Hash_valid_keys_after:58 (TestLinearProbing.java)

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!