subject

Make a sorted integer array a[i]=i, i=0,…,n-1. Let bs(a, n,x) be a binary search program that returns the index i of array a[0..n-1] where a[i]=x. Obviously, the result is bs(a, n,x)=x, and the binary search function can be tested using the loop:
for(j=0; j for(i=0; i
Select the largest n your software can support and then K so that this loop with an iterative version of bs runs 3 seconds or more. Then measure and compare this run time and the run time of the loop that uses a recursive version of bs. Compare these run times using maximum compiler optimization (release version) and the slowest version (minimum optimization or the debug version). If you have a desktop machine, use it. If you must use a laptop, make measurements using AC power, and then the same measurements using only the battery.
What conclusions can you derive from these experiments? Who is faster? Why? What is the time for executing a single bs program? If you have different compilers you can compare them.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:20, destinyleisantos
The kurt vonnegut commencement speech, the neiman-marcus chocolate chip cookie recipe, and the get-well emails to the dying boy are examples of select one: a. social engineering b. hoax emails c. email viruses d. worms
Answers: 1
image
Computers and Technology, 22.06.2019 20:50, ashiteru123
What is the difference between windows 7 and windows 10?
Answers: 1
image
Computers and Technology, 23.06.2019 01:30, solikhalifeoy3j1r
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
image
Computers and Technology, 23.06.2019 16:30, azainababbas
20 points archie wants to use a reflector as he photographs a newlywed couple. what would he consider in his choice? a. shadow and sunny b. homemade and professional c. lamps and boards d. incident and reflected e. neutral density and enhancement
Answers: 3
You know the right answer?
Make a sorted integer array a[i]=i, i=0,…,n-1. Let bs(a, n,x) be a binary search program that return...

Questions in other subjects:

Konu
Mathematics, 01.02.2020 20:43