Calculate the interval by dividing the largest array

Assignment Help JAVA Programming
Reference no: EM131586084

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: EM131586084

Questions Cloud

What is the value of chi-square : What is the value of chi-square? Round to three decimal places.The test evaluates how well the observed frequencies fit the expected frequencies.
Write an essay about parkinsons disease or leukemia : Write an essay about Parkinsons disease or Leukemia. What parts of the world is the disease found? How is it transmitted if it is transmittable?
Which potentially metastatic cancer as per lecture : The stratum spinosum is the location for the cells of which potentially metastatic cancer, as per lecture? The dermis can be best described as a ___________.
Discuss the idea that social mobility is on the decline : Looking at the idea that social mobility is on the decline, what does that make America, in terms of stratification, Is it more akin to a caste system
Calculate the interval by dividing the largest array : Create a for loop that iterates through the smallest array to the largest array and keep adding the interval -
Information on the two machines : Hendricks Pizzeria is considering the purchase of a new Oven to replace a machine that was purchased several years ago.
Describe the state space of pulling a mitten from the box : Problem: In early December 2011, the Yarn Harlot felt "a mitten thing coming on" and, with eight colors of yarn-orange, red, yellow, lime green, forest green.
What alternative investment has the lowest possible : What alternative investment has the lowest possible volatility while having the same expected return as? Microsoft? What is the volatility of this? investment?
State a version of pie for the probabilities of three events : The Minbari have three castes (worker, religious, and warrior), and some Minbari enjoy eating the ceremonial food flarn whereas others do not.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a gui front end for your bubble sort program

Design and implement a Java program which sorts a 10 element integer array using the bubble sort process. The elements of the array to be sorted should be supplied by the user (assume the user will not input duplicates).

  Http://www.homeworkmarket.com/content/need-help-java-program

Write a Java application program that takes in user input from keyboard and calculate semester grade based on the scores. In this assignment, you are going to rewrite the program, instead of taking keyboard input, you will use dialog box to prompt..

  Which statement is true about a non-static inner class

Which statement is true about a non-static inner class? Clicking the closing button on the upper-right corner of a frame generates a(n) _____ event.

  Write a method in java that uses a switch statement

Write a method in JAVA that uses a switch statement and takes a person's age using an integer parameter , then checks if the age is valid (0-110), and then RETURNS a string based on the age

  A class for counting the number of people

Specification: A class for counting the number of people in a room. This might be used to control how many people are allowed into a club with a doorman.

  Determine various currents and voltages

1. To troubleshoot a complex circuit and determine various currents and voltages using mesh analysis. 2. To simulate the complex circuit in MultiSim and record the required quantities.

  App that allows the user to enter a series of numbers

Write an app that allows the user to enter a series of numbers and manipulate them. The app should provide users with the option of adding or multiplying the numbers.

  Write a program that takes cents as an integer and converts

Write a program that takes cents as an integer and converts it to dollars and cents and the conversion should be done in a function called NormalizeMoney.

  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..

  Create an easy to read report layout for the daily report

Create an easy to read report layout (consistent spaces for each column and column headers) for the daily report (HINT: column headers you can use...auto info, price/discounted price, customer info)

  What is the purpose of using javascript on a website

What is the purpose of using JavaScript(r) on a website? What is a specific example of a JavaScript(r) application that will be beneficial on the site you are creating

  Implementing inheritance by creating generic superclass

You will be implementing inheritance by creating a generic Racer superclass along with two subclasses called StreetTuner and HotRod. You will make the Racer class abstract and include the abstract method IsDead in the Racer class

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