Finds if a value of f ( n ) is equal to x where n is in interval [ low . . high ]
def binarySearch ( low , high , x ) : NEW_LINE INDENT while ( low <= high ) : NEW_LINE INDENT mid = int ( ( low + high ) // 2 ) ; NEW_LINE if ( f ( mid ) < x ) : NEW_LINE INDENT low = mid + 1 ; NEW_LINE DEDENT elif ( f ( mid ) > x ) : NEW_LINE INDENT high = mid - 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT return True ; NEW_LINE DEDENT DEDENT return False ; NEW_LINE DEDENT