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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started