Question: Please help with this JAVA program. Thank you! For this assignment you will be writing code to generate test data, as well as benchmark sorting

Please help with this JAVA program. Thank you!

For this assignment you will be writing code to generate test data, as well as benchmark sorting algorithms on it (edited from Sedgewick and Wayne: 2.1.36). First, write a series of methods that generate test data that is non-uniform :

Half the data is 0s, half 1s. For example, an input of length 8 might look like [0, 1, 1, 0, 0, 1, 0, 1]. [5 points]

Half the data is 0s, half the remainder is 1s, half the reminder is 2s, half the reminder is 3s, and so forth. For example, an input of length 8 might look like [0, 0, 1, 3, 0, 1, 2, 0]. [5 points]

Half the data is 0s, half random int values (can use nextInt() from Java's Random package). For example, an input of length 8 might look like [0, 138617093, 0, 54119567, 0, 0, 4968, -650736346]. [5 points]

Each of these three techniques should be implemented as a static method that takes a integer represen- ting the size of a dataset, and returns an integer array containing that number of elements generated with the corresponding rule. Randomize (shu e) the contents of the array after you populate it.

Using the three methods you implement, develop and test hypotheses about the e ect of input on the performance of two of the algorithms (your choice) we have covered. (Get their source code from BlackBoard.)

The program should contain your hypotheses (3 per algorithm) as comments: describe what you think the running time will look like (O(n)? O(n2)? O(n3)?) on each data set, and explain brie y why you think that. As long as your ideas make sense, you will receive full credit on the hypotheses. [8 points]

1

For each of the two sorting algorithms, you should run them on the three types of test data. Test them with datasets size of 2048 and 4096. Time each of these twelve tests with the Stopwatch class given in class. (If your system is so fast you don't get good results, you may increase the dataset size.) [6 points]

Display the result of applying the doubling formula to the run times from the 2048 and 4096 test pairs to get the power ( b ) for that algorithm on that type of input. [6 points]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!