alogrithm analyasis


*  Compilation:  javac
*  Execution:    java Stopwatch n
*  Dependencies: none
*  A utility class to measure the running time (wall clock) of a program.
*  % java8 Stopwatch 100000000
*  6.666667e+11  0.5820 seconds
*  6.666667e+11  8.4530 seconds

*  The {@code Stopwatch} data type is for measuring
*  the time that elapses between the start and end of a
*  programming task (wall-clock time).
*  See {@link StopwatchCPU} for a version that measures CPU time.
*  @author Robert Sedgewick
*  @author Kevin Wayne
public class Stopwatch {

   private final long start;

    * Initializes a new stopwatch.
   public Stopwatch() {
       start = System.currentTimeMillis();
    * Returns the elapsed CPU time (in seconds) since the stopwatch was created.
    * @return elapsed CPU time (in seconds) since the stopwatch was created
   public double elapsedTime() {
       long now = System.currentTimeMillis();
       return (now – start) / 1000.0;

    * Unit tests the {@code Stopwatch} data type.
    * Takes a command-line argument {@code n} and computes the
    * sum of the square roots of the first {@code n} positive integers,
    * first using {@code Math.sqrt()}, then using {@code Math.pow()}.
    * It prints to standard output the sum and the amount of time to
    * compute the sum. Note that the discrete sum can be approximated by
    * an integral – the sum should be approximately 2/3 * (n^(3/2) – 1).
    * @param args the command-line arguments
   public static void main(String[] args) {
       int n = Integer.parseInt(args[0]);

       // sum of square roots of integers from 1 to n using Math.sqrt(x).
       Stopwatch timer1 = new Stopwatch();
       double sum1 = 0.0;
       for (int i = 1; i <= n; i++) {            sum1 += Math.sqrt(i);        }        double time1 = timer1.elapsedTime();        StdOut.printf("%e (%.2f seconds)n", sum1, time1);        // sum of square roots of integers from 1 to n using Math.pow(x, 0.5).        Stopwatch timer2 = new Stopwatch();        double sum2 = 0.0;        for (int i = 1; i <= n; i++) {            sum2 += Math.pow(i, 0.5);        }        double time2 = timer2.elapsedTime();        StdOut.printf("%e (%.2f seconds)n", sum2, time2);    } }CS520 Algorithm Analysis Programming Assignment 2 – Run Time Observation 25+5 points Write a program that will perform the following tasks, in turn 1. Randomly generates n integer numbers (to avoid duplicates, we want the range of the data be much greater than the size of the data) and save them in an array data structure 2. Sort these numbers in order 3. Randomly generate m numbers, for each number, perform the following two search algorithms on the array, record the actual search time (either target is found, or not). 3.1 linear search algorithm 3.2 binary search algorithm 4. create a report that has the following format: Data size (n) 100 search entries (m) 50 10,000 1000 1e6 1000 1e8 1000 # of found Average time spent linear search Average time spent binary search Items to be submitted 1. source code(s) 2. a document that contains the report table 3. a readme file that simply explains how to run the code Extra credit: Add a space observation component in your project, so for each data size, you also report how much memory is used. Hint: Refer to file for managing time stamps. Refer to for measuring memory usage. Purchase answer to see full attachment

We offer the bestcustom writing paper services. We have done this question before, we can also do it for you.

Why Choose Us

  • 100% non-plagiarized Papers
  • 24/7 /365 Service Available
  • Affordable Prices
  • Any Paper, Urgency, and Subject
  • Will complete your papers in 6 hours
  • On-time Delivery
  • Money-back and Privacy guarantees
  • Unlimited Amendments upon request
  • Satisfaction guarantee

How it Works

  • Click on the “Place Order” tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
  • Fill in your paper’s requirements in the "PAPER DETAILS" section.
  • Fill in your paper’s academic level, deadline, and the required number of pages from the drop-down menus.
  • Click “CREATE ACCOUNT & SIGN IN” to enter your registration details and get an account with us for record-keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
  • From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.