def binary_search(arr, k):
    """
    Implement nonrecursive binary search
    :param arr: an array sorted in ascending order
    :param k: seach key K
    :return: an index of array element that is equal to k
    """
    l = 0
    r = len(arr) - 1
    while l <= r:
        m = (l+r) // 2
        if k == arr[m]:
            return m
        elif k < arr[m]:
            r = m - 1
        else:
            l = m + 1
    return -1