Write a program called insertionsortbenchmark

Assignment Help JAVA Programming
Reference no: EM131578963

Write a program called InsertionSortBenchmark that automatically generates a table of sample run times for the insertion sort algorithm. The program should ask for the smallest and largest value of n and the number of measurements and then execute all sample runs. You should plan to have a method (e.g., "public static int[] generateData(int n)") in your program that generates int arrays of a specific length and populates them with random numbers (use Random's nextInt). This will be needed to run the different tests. To time the running algorithm, you will need to use the StopWatch class (see attached). Also attached is InsertionSorter.java, which contains an implementation of insertion sort. The algorithm is available as a static method directly from that file.

I just need help with the portion in bold. This is the hint from the instructor:

You need to calculate the interval by dividing the largest array size by the number of measurements:
int interval = largest / measurement;

Create a for loop that iterates through the smallest array to the largest array and keep adding the interval.

This is what I have written so far, but I am having issues setting up the loop:

public static int[] generateData(int n)
{
Scanner in = new Scanner(System.in);
int counter = 0;
Random randomNum = new Random();

System.out.print("Smallest array size: ");
int smallest = in.nextInt();
System.out.print("Largest array size: ");
int largest = in.nextInt();
System.out.print("number of measurement: ");
int measurements = in.nextInt();
int [] unsortedArray = new int[smallest];

while (counter < measurements)
{


}

return unsortedArray;

}

Reference no: EM131578963

Questions Cloud

Descriptions of particularly important issues : Using the firm you have chosen, outline a thorough outline for the audit that includes descriptions of particularly important issues to be dealt.
Expected payoff at the risk-free interest rate : Assuming that all interest rates are compounded annually, and that investors value risky bonds by discounting the expected payoff at the risk-free interest rate
Describe how a technician would collect a fingerprint : Describe how a technician would collect a fingerprint from a weapon that could possibly have touch DNA on it as well as fingerprints
Implements the comparable interface : Create a class called Dog that implements the Comparable interface. Dog will contain a member variable to hold a name, a constructor that sets up the name
Write a program called insertionsortbenchmark : Write a program called InsertionSortBenchmark that automatically generates a table of sample run times for the insertion sort algorithm.
Write paper that either supports or refutes : Write paper that either supports or refutes statistical data as a means of supporting criminal justice policy
Discuss the corporate culture at whole foods market : Discuss the corporate culture at Whole Foods Market. Recall that the corporate culture consists of the widely shared values within an organization.
Returns for large-company stocks and treasury bills : Using the annual returns for large-company stocks and Treasury bills, calculate both the 5- and 10-year rolling average return and standard deviation.
Write a test program that prompts the user : Write a test program that prompts the user to enter two complex numbers and displays the result of their addition, subtraction, multiplication, division

Reviews

Write a Review

JAVA Programming Questions & Answers

  What are the limits for each one of these indexes

What are the limits for each one of these indexes and is it possible to model a 2-dimensional array with a single-dimensional array?

  Credit card expenses

You started recording every credit card transaction so that you can analyze your monthly expenses. You used an Excel worksheet to track dates, places, categories, and amounts. Because you are a consultant who travels periodically, you also have bu..

  1 what makes a program easy to modify2 describe the order

1. what makes a program easy to modify?2. describe the order of magnitude of the following code section using bigo

  Compare swing java gui components to awt components

Compare Swing Java GUI components to AWT components. Explain at least one way the components are similar and at least one way they are different.

  Recognize one high severity vulnerability for computer

Recognize one high severity vulnerability for each computer (if there is one). Explain vulnerability and describe control(s) to minimize risk from vulnerability.

  Need a console program

Need a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed).

  Write a simple program that uses the class

Write a simple program that uses the class. It should prompt the user to input a string, display it, call one or the other of the class functions to convert it, then display the converted string.

  Assignmentwrite a gui-based application that allows a user

assignmentwrite a gui-based application that allows a user to play a simple trivia game. the game should have 5

  You need to train for 10 weeks

You are preparing for a marathon. In order to prepare, you need to train for 10 weeks, running an increasing number of miles per week, starting at running at least 2 miles your first week up to 26 miles by week 10.

  Find a java application on the web and describe it

What functionality does the application have that you have learned about in this class?

  Create a constant to hold the desired duration of workout

Creates an instance of the FiFiWorkout.java class. Gets input for first name. Create a constant to hold the desired duration of workout. Set it to 30.

  Design and implement a small and simple email server using

design and implement a small and simple email server using the concept of web based information system wbis. your

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd