All pastes #354949 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-02-14 06:34 UTC
rendered paste body
BinarySearch( A, value ) {
       low = 0
       high = N + 1
       p = (high+low)/2
       while ( low < high ) {
           if ( A[p] > value )
               high = p
           else if ( A[p] < value )
               low = p
           else
               return p
           p = (high+low)/2
       }
       return not_found
   }