Answer the question
In order to leave comments, you need to log in
How to write an algorithm for binary search on an array with C numbers?
I want to write an algorithm myself, without peeping, but I can’t figure out how to get the array indices. Those. here we have an array, its size is 500 cells, we take the 250th cell, find out that the desired value is to the right. Accordingly, the search area is now from 250 to 500, and the size of the second half is 250. You can copy the second half of the array to another array and then the indices will start from zero, but then what's the point of a binary search?
Give me an idea please. How can I get the correct array indexes?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question