def binary_search(input_list, number, min_idx, max_idx):
    """
     Find the index for a given value (number) by searching in a sorted array
     
     Time complexity: O(log2(n))
     Space Complexity: O(1)
    
     Args:
         - input_list(array): sorted array of numbers to be searched in
         - number(int): number to be searched for

     Returns:
        - position(int): reuturns array index for the given number
                         returns -1 when the number was not found
    """
    # corner case for case when provided min_idx is higher than provided max_idx
    if max_idx < min_idx: 
        return -1
    
    # binary search
    while min_idx <= max_idx:
        mid = (min_idx + max_idx) // 2

        # Check if x is present at mid
        if input_list[mid] == number:
            return mid
        
        # If the guess was too low, set min to be one larger than the guess
        if input_list[mid] < number:
            min_idx = mid + 1
      
        # If the guess was too high, set max to be one smaller than the guess
        else:
            max_idx = mid - 1

    # if we got here, the number was not found
    return -1