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, 21.06.2019 20:50
What does operator overloading allow you to do?
Answers: 2
question
Computers and Technology, 21.06.2019 23:00
In a file-oriented information system, a work file stores relatively permanent data about an entity is created and saved for backup and recovery purposes stores records that contain day-to-day business and operational data is a temporary file created by an information system for a single task
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
What is the worst-case complexity of the maxrepeats function? assume that the longest string in the names array is at most 25 characters wide (i.e., string comparison can be treated as o( class namecounter { private: int* counts; int nc; string* names; int nn; public: namecounter (int ncounts, int nnames); int maxrepeats() const; }; int namecounter: : maxrepeats () { int maxcount = 0; for (int i = 0; i < nc; ++i) { int count = 1; for (int j = i+1; j < nc; ++j) { if (names[i] == names[j]) ++count; } maxcount = max(count, maxcount); } return maxcount; }
Answers: 3
question
Computers and Technology, 23.06.2019 16:00
An english teacher would like to divide 8 boys and 10 girls into groups, each with the same combination of boys and girls and nobody left out. what is the greatest number of groups that can be formed?
Answers: 2
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, 09.11.2020 18:50
question
Chemistry, 09.11.2020 18:50
question
English, 09.11.2020 18:50
question
Mathematics, 09.11.2020 18:50
question
English, 09.11.2020 18:50
Questions on the website: 13722363