Does anyone know how to do this? This is an assignment that I am working on for
ID: 3549490 • Letter: D
Question
Does anyone know how to do this? This is an assignment that I am working on for my Algorithm course and it has to done using NetBeans IDE 7.4. Here's how it works:
Write a program to evaluate the execution time for several types of program structures. Use the Stopwatch class described below:
public class Stopwatch:
Stopwatch () create a stopwatch
double elapsedTIme() return elapsed time since creation
typical client:
public static void main(String[] args)
{
int N = Integer.parseInt(args[0]);
int[] a = new int[N];
for (int i = 0; i < N; i++)
a[i] = StdRandom.uniform(-1000000, 1000000);
Stopwatch timer = new Stopwatch();
int cnt = ThreeSum.count(a);
double time = timer.elapsedTime();
StdOut.printIn(cnt +
Explanation / Answer
/** * Replace this line with class description. * * User: George Sun * Date: 9/15/13 * Time: 9:45 PM */ public class SortCompare { public static void main(String[] args) { String alg1 = args[0]; String alg2 = args[1]; int N = Integer.parseInt(args[2]); int T = Integer.parseInt(args[3]); double t1 = timeRandomInput(alg1, N, T); double t2 = timeRandomInput(alg2, N, T); StdOut.printf("For %d random Doubles %s is: ", N, alg1); StdOut.printf(" %1f times faster than %s ", t2 / t1, alg2); } public static double timeRandomInput(String alg, int N, int T) { double total = 0.0; Double[] a = new Double[N]; for (int t = 0; tRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.