def binary_search(array, search_term):
    """
    Binary search algorithm for finding an int in an array.
    Returns index of first instance of search_term or None.
    """
    p = 0
    r = len(array) - 1
    while p <= r:
        q = (p + r) // 2
        value = array[q]
        if value == search_term:
            return q
        elif value > search_term:
            r = q - 1
        else: # value < search_term
            p = q + 1
    return None