please answer correctly Algorithm Running Time package test; import java.util. *; import java.util.Random; public class Test { private long start = 0; public Test() { start = System.currentTimeMillis(); } public double elapsedTime() { long now = System.currentTimeMillis(); return (now - start) / 1000.0; } private static long constant_value(long paramInt) { long l = 0L; for (int i = 0; i < paramInt; i++) l += 1L; return l; } private static long logarithmic(long paramInt1, long paramInt2) { long l = 0L; for (int i = 1; i + i <= paramInt1; i += i) l += constant_value(paramInt2); return l; } private static long sqrt(long paramInt1, long paramInt2) { long l = 0L; int i = 0; for (int j = 0; j < paramInt1; i++) { l += constant_value(paramInt2);j += i; } return l; } public static long linearithmic(long paramInt1, long paramInt2) { if (paramInt1 == 0) return 0L; long l = 0L; for (int i = 0; i < paramInt1; i++) l += constant_value(paramInt2); return linearithmic(paramInt1 / 2, paramInt2) + l + linearithmic(paramInt1 / 2, paramInt2); } private static long linear(long paramInt1, long paramInt2) { long l = 0L; for (int i = 0; i < paramInt1; i++) l += constant_value(paramInt2); return l; } private static long linearsqrt(long paramInt1, long paramInt2) { long l = 0L; for (int i = 0; i < paramInt1; i++) { l += sqrt(paramInt1, paramInt2); } return l; } private static long quadratic(long paramInt1, long paramInt2) { long l = 0L; for (int i = 0; i < paramInt1; i++) for (int j = 0; j < paramInt1; j++) l += constant_value(paramInt2); return l; } private static long exponential(long paramInt1, long paramInt2) { if (paramInt1 == 0) return constant_value(paramInt2); return exponential(paramInt1 - 1, paramInt2) + exponential(paramInt1 - 1, paramInt2); } private static long factorial(long paramInt1, long paramInt2) { if (paramInt1 == 0) return constant_value(paramInt2); long l = 0L; for (int i = 0; i < paramInt1; i++) l += factorial(paramInt1 - 1, paramInt2); return l; } static Scanner input = new Scanner(System.in); public static void main(String[] args) { long n; long x; int y; Random randomno = new Random(); randomno.setSeed(777280); System.out.print("Enter value for N: "); n = input.nextInt(); Test timeStart = new Test(); x = factorial(n, 20); double timer1 = timeStart.elapsedTime(); System.out.print("Value: "+ x ); System.out. println("\tTime Elapsed: " + timer1); } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please answer correctly

Algorithm Running Time

 

package test;

import java.util. *;

import java.util.Random;

 

public class Test {

 private long start = 0;

 

   

    public Test() {

        start = System.currentTimeMillis();

    }

 

    public double elapsedTime() {

        long now = System.currentTimeMillis();

        return (now - start) / 1000.0;

    }

 private static long constant_value(long paramInt) {

    long l = 0L;

    for (int i = 0; i < paramInt; i++)

      l += 1L;

    return l;

  }

 

  private static long logarithmic(long paramInt1, long paramInt2) {

    long l = 0L;

    for (int i = 1; i + i <= paramInt1; i += i)

      l += constant_value(paramInt2);

    return l;

  }

  private static long sqrt(long paramInt1, long paramInt2) {

    long l = 0L;

    int i = 0; for (int j = 0; j < paramInt1; i++) {

      l += constant_value(paramInt2);j += i;

    }

    return l;

  }

 

   public static long linearithmic(long paramInt1, long paramInt2) {

    if (paramInt1 == 0) return 0L;

    long l = 0L;

    for (int i = 0; i < paramInt1; i++)

      l += constant_value(paramInt2);

    return linearithmic(paramInt1 / 2, paramInt2) + l + linearithmic(paramInt1 / 2, paramInt2);

  }

   private static long linear(long paramInt1, long paramInt2) {

    long l = 0L;

    for (int i = 0; i < paramInt1; i++)

      l += constant_value(paramInt2);

    return l;

  }

   private static long linearsqrt(long paramInt1, long paramInt2) {

    long l = 0L;

    for (int i = 0; i < paramInt1; i++) {

      l += sqrt(paramInt1, paramInt2);

    }

    return l;

  }

   private static long quadratic(long paramInt1, long paramInt2) {

    long l = 0L;

    for (int i = 0; i < paramInt1; i++)

      for (int j = 0; j < paramInt1; j++)

        l += constant_value(paramInt2);

    return l;

  }

 

  private static long exponential(long paramInt1, long paramInt2) {

    if (paramInt1 == 0) return constant_value(paramInt2);

    return exponential(paramInt1 - 1, paramInt2) + exponential(paramInt1 - 1, paramInt2);

  }

 

  private static long factorial(long paramInt1, long paramInt2) {

    if (paramInt1 == 0) return constant_value(paramInt2);

    long l = 0L;

    for (int i = 0; i < paramInt1; i++)

      l += factorial(paramInt1 - 1, paramInt2);

    return l;

  }

      static Scanner input = new Scanner(System.in);

   

    public static void main(String[] args) {

      long n;

        long x;

        int y;

       

       Random randomno = new Random();

       randomno.setSeed(777280);

      

        System.out.print("Enter value for N: ");

        n = input.nextInt();

       

        Test timeStart = new Test();

         x = factorial(n, 20);

        double timer1 = timeStart.elapsedTime();

        System.out.print("Value:  "+ x );

        System.out. println("\tTime Elapsed: " + timer1);

      

    }

   

}

Instructions:
Test the running time of the set of algorithms provided found in Lab Activity 1 resources above this activity. Modify the codes to be able to
determine the actual running of the algorithm for two (2) parameters declared in each method except the CONSTANT method having only one
(1) parameter.
Value: Parameter 1 Parameter 2
Parameter 1
Parameter 2
5
20
10
20
15
20
20
20
25
20
Plot the results of Time Elapsed and Computed Value using Line Graph and Bar Chart in EXCEL using the table of values above. Save the file in
EXCEL showing the graph. Name the file using your LASTNAME.
Transcribed Image Text:Instructions: Test the running time of the set of algorithms provided found in Lab Activity 1 resources above this activity. Modify the codes to be able to determine the actual running of the algorithm for two (2) parameters declared in each method except the CONSTANT method having only one (1) parameter. Value: Parameter 1 Parameter 2 Parameter 1 Parameter 2 5 20 10 20 15 20 20 20 25 20 Plot the results of Time Elapsed and Computed Value using Line Graph and Bar Chart in EXCEL using the table of values above. Save the file in EXCEL showing the graph. Name the file using your LASTNAME.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY