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, 24.06.2019 03:30
Explain the importance of html in web page designing in 20 sentences..
Answers: 1
question
Computers and Technology, 24.06.2019 07:00
Why do we mark tlc plates with pencil and not with pen
Answers: 2
question
Computers and Technology, 25.06.2019 04:20
Many prestigious universities have a system called a “legacy preference system” which is used to decide which applicants should be accepted to the university. if an applicant’s parent is an alumnus of the university, the applicant will be admitted with lower gpa and sat scores than if the parent is not an alumnus. (there is currently a lot of discussion about the fairness of this system, but universities get a lot of money from their alumni so they are unwilling to change ) your assignment for mp2 is to implement a computerized system like this for a very small prestigious university. the university has two schools, liberal arts and music, each with their own criteria for accepting students. your program must read in certain information about an applicant and print a message saying whether the applicant should be accepted or not.
Answers: 2
question
Computers and Technology, 25.06.2019 04:30
What should be used when performing vehicle maneuvers?
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
question
Mathematics, 18.08.2020 14:01
question
Mathematics, 18.08.2020 14:01
question
Spanish, 18.08.2020 14:01
Questions on the website: 13722361