Binary Search For Infinite Array
Binary Search For Infinite Array
You are given an infinite sized array which is sorted and you need to find out the index of the element
that will be given to you by us, let say x=700.
Naive Approach
Itterating over the array and searching the element , in this approach 2 cases arises :
Efficient Approach
Make a seprate case for the 0th index and start from index=1 and each time multiply it by 2 search
for the element is you encounter a case where current element - greater than the desired element
then you will get a Bounded region in which 2 things are for sure that :