Help with Binary Search

Back to General discussions forum

Christopher Matthews     2014-11-02 11:01:33

I'm having some difficulty understanding the Binary Search algorithm... I understand that in order to begin, I need to choose some values for minimum and maximum. Obviously I would start with 0 for the minimum value, but how would I go about finding the maximum? I read the wiki several times, but I'm afraid I still don't understand it quite well enough... any help would be appreciated!

Thank you,

Christopher Matthews

Rodion (admin)     2014-11-02 20:30:30
User avatar

Hi! If you mean the Binary Search problem then please note the statement says Solution is guaranteed to exist somewhere in range 0 <= x <= 100 - so for solving this task you may choose 100 (or any greater value) as the upper bound.

In real cases we may before applying the algorithm perform calculation of target function in several random points to find out what could be chosen as a proper bound, or use some analytical approach to judge where to start. In this sense your question is wise enough - we really never have apriory idea of the suitable range for some arbitrary chosen function so we may need to study its behavior first.

Please login and solve 5 problems to be able to post at forum