Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

3. What may be the goal of the team?

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago