Given an N sorted elements in the beginning of an infinite array, find if a given k elements exists in the array in O(logN) time, or return proper message if element does not exist.
What i have come up with so far is a modification of binary search since we dont know the length of array(we know its infinite but we dont know N) i use this:
if k > A[i] then let i = i*2
If k == A[i], then we re done, otherwise we do binary search as usual on A[1..i].
The only problem is that with this pseudocode i am afraid the time it will take to make the search will be higher than O(logN) since there is a chance that we will run multiple binary searches so its gonna be something of O(klogN).
Any ideas??