Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is the maximum number of guesses needed in the binary search in the range 1 to n?

0
Posted

What is the maximum number of guesses needed in the binary search in the range 1 to n?

0

A binary search is an efficient search mechanism for a list of N data values which are sorted according to a well defined criterion (for example, in alphabetical or numerical order). Essentially this means that the comparison of the known target value with an arbitrary member of the list will yield one of three results: the two are the same, ie the search is complete, or the target value lies above or below the current position. The strategy is simple. The centre value of the N data points is selected and a comparison with the target value made. If unsuccessful, the position of the required element in the list is known to be either above or below the current position. This enables half of the data values to be rejected, and the procedure repeated on the remaining half (hence ‘binary search’). In the worst case the search will be successful when the number of remaining data values has been reduced to one; this occurs the first time the number n of steps or guesses meets the condition 2^

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123