Question: Write Java code to generate an array of 1 million consecutive integers. How long in nanoseconds does it take to find the number 499999 in

Write Java code to generate an array of 1 million consecutive integers. How long in nanoseconds does it take to find the number 499999 in this array (on your computer) using the binary search algorithm? (40 points)

3. Double the number of consecutive integers to 2 million. How long in nanoseconds does it take to find the number 499999 in this array (on your computer) using the binary search algorithm? (40 points)

4. Do these results confirm the O(log n) complexity? (10 points)

5. Confirm the complexity of the selection sort by writing code that times in nanoseconds or milliseconds the execution of a selection sort for n, 2n and 4n. It is left to you to select n. Submit the code.(50 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!