javarecursionbinary

Recursion and Binary Searching


So I was reading about Recursive searching in a binary search algorithm and I saw a line that says, that with every computation where you don't find the result, you cut the array you are looking through in half and create a new array. Is it really necessary to make a new array with every computation instead of adjusting the start and end index of the array you started with?


Solution

  • sure you can just adjust the start and end index. This is the implementation. What you are reading is an easy description of the algorithm, the implementation can differ if it still does the work.