Question
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 java.util.Dictionary; import static javax.swing.UIManager.get; public class TestPerf { // this
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 java.util.Dictionary;
import static javax.swing.UIManager.get; public class TestPerf { // this is used to read a file and build table private ST
public TestPerf() { lh = new ST<>(); ch = new SeparateChainingHashST<>(); lp = new SequentialSearchST
// this is used to read a file and build table public static long LinearProbingHashST(String x[]) { var 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 static long SeparateChainingHashST(String x[]) { var st = new SeparateChainingHashST(); 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 static long ST(String x[]) { var st = new ST(); 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 static long SequentialSearchST(String x[]) { var st = new SequentialSearchST(); 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(String filename) { In in = new In(filename); st = new ST
public void printStats() {
System.out.println(timer); System.out.println(+sth); System.out.println(sths); System.out.println(Sequential); System.out.println(getMostUsedWord()); System.out.println(getTotalWords()); System.out.println(getUniqueWords()); System.out.println(getMaxOccurrence() + "" + getMostUsedWord()); }
//main function public static void main(String[] args) { TestPerf test = new TestPerf(args[0]); test.printStats(); } }
whAT AM I DOING WRONG HERE AND IT IS NOT COMPILING OR RUNNING I CAN NOT FIGURE THIS OUT i AM STUCK
in JAVA HW
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started