Question: This exercise is to test the efficiency of different sorting algorithms. The program requires random numbers to be gener ated for the array. An object
This exercise is to test the efficiency of different sorting algorithms. The program requires random numbers to be gener ated for the array. An object from Random class (in java.util package) is used to get random numbers. Create an integer array of size 1000000 and do the following:
1. Assign the array elements with random numbers . (Call nextInt() )
2. Get the current time System .currentTimeMillis() and store it in a variable (start).
3. Call selection sort.
4. Get the current time System.currentTimeMillis() and store it in a variable (end).
5. Print the difference end start.
6. Redo steps 1 to 5 for merge sort & quick sort.
7. Which of these three algorithms give the best time??
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
