I am performing a binary search , let say i have to find the minimum value of x such that black_box(x) gives me true result.
Property of black_box(x)
- If
black_box(x)gives me true thenx+1,x+2,x+3,x+4....upto infintyall gives metrue
For Integer Value this is simple binary search
start=0;
end = Max;
ans=-1;
while(start<=end){
mid =(start+end)/2;
if(black_box(mid)):
end =mid-1
ans=mid;
else: start=mid+1;
}
What if i want a floating point integer upto 2 decimal , how should i do binary search ?
end = Inf, how can you determine the middle of it? Even forints that's not the case.BigIntegerin Java.