Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probability & Statistics For Engineers & Scientists

Authors: Ronald E. Walpole, Raymond H. Myers, Sharon L. Myers, Keying

7th Edition

9789813131279, 130415294, 9813131276, 978-0130415295

Students also viewed these Databases questions