Question: In this exercise you are asked to empirically compare two sorting algorithms, Both with a worst - case running time of O ( n ^

In this exercise you are asked to empirically compare two sorting algorithms, Both with a worst-case running time of O(n^2). In particular, we would like to know for which length of input arrays the second algorithm is faster than the first. Proceed as follows: 1. Write a Java program implementing the Selection sort algorithm. 2. Write a Java program implementing the Quick Sort algorithm. 3. Compare the performance of the two algorithms: (a) Write code that generates a random array A, then runs each algorithm on A, and records the time. (b) Repeat this for several arrays of the same size, still recording the running times. (c) Gradually increase the size of the arrays, until you see that one algorithm is consistently faster than the other.

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 Programming Questions!