subject

A binary search algorithm is written which searches a pre-sorted array for some user-defined value, clientData. If clientData is stored in the array, it returns its array position, and if not found, it returns -1 (again, just like in the modules). Assume the array to be searched has 100 data elements in it. (Check all that apply). HINT: Each recursive call throws away half of the elements it gets. The method gets 100 elements, but if clientData is not found in position 49 (first comparison) the method throws 51 of those elements away and calls itself. This inner call now has 49 elements to search. It tests element 24 against clientData (second comparison), and if it is not a match, throws about away half again, leaving 24. The next call/comparison, if needed, throws away about 12. The next call, if needed, throws away 6. The next call throws away 3. The next call throws away 2. Finally we only have one element to test. Each recursive call does one comparison. How many comparisons have we done, give or take one, (count above) in the worst case, assuming we have to go all the way down until we only have one element before we find the data we are searching for

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:10
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 1
question
Computers and Technology, 23.06.2019 02:30
Three out of five seniors remain undecided about a college major at the end of their senior year.
Answers: 3
question
Computers and Technology, 23.06.2019 18:40
Johnson enterprises uses a computer to handle its sales invoices. lately, business has been so good that it takes an extra 3 hours per night, plus every third saturday, to keep up with the volume of sales invoices. management is considering updating its computer with a faster model that would eliminate all of the overtime processing.
Answers: 2
question
Computers and Technology, 23.06.2019 23:30
What can you prevent issues related to downloading content form the internet
Answers: 1
You know the right answer?
A binary search algorithm is written which searches a pre-sorted array for some user-defined value,...
Questions