(arr, item)
return found
Binary Search
        Complexity: O(log(n))
        Only works on sorted arrays
Binary Search
        Complexity: O(log(n))
        Only works on sorted arrays
Binary Search Complexity : O ( log ( n )) Only works on sorted arrays
def binary_search(arr, item):
    """ Binary Search
        Complexity: O(log(n))
        Only works on sorted arrays
    """
    first = 0
    last = len(arr)-1
    found = False

    # Note that first and last will get closer!
    while first <= last and not found:
        # Divide problem set
        mid = (first+last)//2
        if arr[mid] == item:
            found = True
        else:
            # Decide which half to search next
            if item < arr[mid]:
                last = mid - 1
            else:
                first = mid + 1
    return found
def binary_search ( arr , item ) : first = 0 last = len ( arr ) - 1 found = False # Note that first and last will get closer! while first <= last and not found : # Divide problem set mid = ( first + last ) // 2 if arr [ mid ] == item : found = True else : # Decide which half to search next if item < arr [ mid ] : last = mid - 1 else : first = mid + 1 return found