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

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 00:30
Match the sentence fragment in the first column with the appropriate ending in the second column. a little per favore?
Answers: 1
question
Computers and Technology, 24.06.2019 09:50
Suppose you are an ad-serving company and you maintain a log of cookie data for ads you serve to the web pages for a particular vendor (say amazon). a. how can you use this data to determine which are the best ads? b. how can you use this data to determine which are the best ad formats? c. how could you records of past ads and ad clicks to determine which ads to send to a given ip address? d. how could you use this data to determine how well the technique you used in your answer to part c was working? e. how could you use this data to determine that a given ip address is used by more than one person? f. how does having this data give you a competitive advantage vis-à-vis other ad-serving companies?
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
Append and make table queries are called queries. select complex simple action i think action
Answers: 1
question
Computers and Technology, 25.06.2019 05:00
What should you do if a dialog box covers an area of the screen that you need to see?
Answers: 1
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
question
Physics, 18.09.2021 14:20
question
Mathematics, 18.09.2021 14:20
question
Mathematics, 18.09.2021 14:20
question
Biology, 18.09.2021 14:20
Questions on the website: 13722362