Posted By

brianyang on 01/30/11


Tagged


Versions (?)

iterative code example


 / Published in: C++
 

iterative analog of the recursive binary search

  1. int iterBinarySearch( int[] array, int lower, int upper, int target ){ int center, range;
  2.  
  3. if( lower > upper )
  4. return LIMITS_REVERSED;
  5.  
  6. while( true ){
  7. range = upper - lower;
  8. if( range == 0 && array[lower] != target )
  9. }
  10. }

Report this snippet  

You need to login to post a comment.