def binary_search(arr, target):
    """
    Searches for first occurance of the provided target in the given array.
    If target found then returns index of it, else None
    Time Complexity = O(log n)
    Space Complexity = O(1)
    """
    first = 0; last = len(arr) - 1
    while first <= last:
        # calculate mid point
        mid = (last + first) // 2
        # target found then return else adjust first and last
        if arr[mid] == target: 
            return mid
        if arr[mid] > target:
            # search left
            last = mid - 1
        if arr[mid] < target:
            # search right
            first = mid + 1
    return None