Binary Search on Double

Правка en3, от arftdipto, 2020-02-14 10:31:00

Can anyone suggest me a good blog for binary search on double ? I found these type of implementation on different blog but failed to manage explanation. Could anyone explain it ?

I found these type of implementation on different blog without explanation. Could anyone explain it ? Type 1:

include<bits/stdc++.h>

using namespace std;

//We want to find an element which a<0.0000001

const float target = 0.0000001;

int main() { float l=0.00000000,r=100000.00000000; cout << l << " " <0.0000000001){ float mid = (float)((l+r)/2); cout << mid <target) r=mid; else l=mid; }cout << l; } Type 2:

int iterations = 0; while(iterations < 300) { // your binary search logic iterations++; }

Теги #binary search, double

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en7 Английский arftdipto 2020-02-14 11:23:37 0 (published)
en6 Английский arftdipto 2020-02-14 11:05:08 49 (saved to drafts)
en5 Английский arftdipto 2020-02-14 10:56:15 627
en4 Английский arftdipto 2020-02-14 10:48:56 706 Reverted to en1
en3 Английский arftdipto 2020-02-14 10:31:00 136
en2 Английский arftdipto 2020-02-14 10:29:18 574
en1 Английский arftdipto 2020-02-14 09:16:27 86 Initial revision (published)