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
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