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
Get step-by-step solutions from verified subject matter experts
