arftdipto's blog

By arftdipto, history, 9 months ago, In English

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 please ?

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 << " " << r;
    while((r-l)>0.0000000001){
        float mid = (float)((l+r)/2);
        cout << mid << endl;
        if(mid>target) r=mid;
        else l=mid;
    }cout << l;
}

Type 2:

int iterations = 0;
while(iterations < 300)
{
  // your binary search logic
  iterations++;
}
 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
9 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by arftdipto (previous revision, new revision, compare).

»
9 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by arftdipto (previous revision, new revision, compare).

»
9 months ago, # |
  Vote: I like it 0 Vote: I do not like it

This one is good

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks :D

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Pashka goes into a lot of detail regarding the implementation issue you raised in your post. Look at his posts on EDU Binary Search. I suffered from the same EPS nightmare until I went through his tutorials.

First register for the EDU. Then: Link for the post