mirror of
https://github.com/Hizenberg469/Algorithms-snippets.git
synced 2026-04-19 22:52:23 +03:00
Seaching Algorithms
This commit is contained in:
15
Searching/advanced_binary_search.cpp
Normal file
15
Searching/advanced_binary_search.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
//Advanced Binary Seach.
|
||||
int max_iter;
|
||||
double low , high , ans;
|
||||
double err ;
|
||||
for(int i = 1 ; i <= max_iter ; i++ ){
|
||||
double mid = low + (high - low)/2;
|
||||
|
||||
if( check(mid) ){
|
||||
ans = mid;
|
||||
low = mid + err;
|
||||
}
|
||||
else{
|
||||
high = mid - err;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user