Advertisement
KillerBananaZ

Recap 1: Cautare binara C++

Nov 24th, 2017
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. Cautare binara in vector sortat
  2.  
  3. li=0;
  4. lf=n-1;
  5. ok=0;
  6. while (li<=lf && ok==0)
  7. {
  8. int mij=(li+lf)/2;
  9. if(v[mij]==k) (val cautata)
  10. ok=1;
  11. else
  12. if(k<v[mij])
  13. lf=mij-1;
  14. else
  15. li=mij+1;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement