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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic 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