arrays - What's the name of this method to find a value in a very efficient way -


If you have a table / array with lots of sorted int values, and Rather than finding one you want, instead of finding one, I know that this is a very efficient method that does this: First of all, it goes to the middle element if the element value is from the value searched It is more, then it ignores all the elements above one and goes to the middle, then it goes up in the middle. And it continues until the value is found.

This will be something in pseudo

  search_value = x real_index = length (array) / 2 offset = real_index while (true) {if array [actual_index] = search_value Then actual_irect if array [actual_index] & gt; I know that this method has a name, it is detected again / output = round_down (offset / 2) real_index = real_indack - offset off offset = round_up (offset / 2) real_indix = but i can not miss it   

I believe that you are thinking of a binary search. / P>

I do not know what language you are working in, but this can be an API call.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -