def      a__ (		__UpperCamelCase     ,      __UpperCamelCase				):
      SCREAMING_SNAKE_CASE_          =  0
      SCREAMING_SNAKE_CASE_          =  len(__UpperCamelCase				) - 1

      while left <= right:
            # avoid divided by 0 during interpolation
            if sorted_collection[left] == sorted_collection[right]:
                  if sorted_collection[left] == item:
                        return left
                  else:
                        return None

            SCREAMING_SNAKE_CASE_          =  left + ((item - sorted_collection[left]) * (right - left)) // (
                sorted_collection[right] - sorted_collection[left]
            )

            # out of range check
            if point < 0 or point >= len(__UpperCamelCase				):
                  return None

            SCREAMING_SNAKE_CASE_          =  sorted_collection[point]
            if current_item == item:
                  return point
            else:
                  if point < left:
                        SCREAMING_SNAKE_CASE_          =  left
                        SCREAMING_SNAKE_CASE_          =  point
                  elif point > right:
                        SCREAMING_SNAKE_CASE_          =  right
                        SCREAMING_SNAKE_CASE_          =  point
                  else:
                        if item < current_item:
                              SCREAMING_SNAKE_CASE_          =  point - 1
                        else:
                              SCREAMING_SNAKE_CASE_          =  point + 1
      return None


def      a__ (		__UpperCamelCase     ,      __UpperCamelCase     ,      __UpperCamelCase     ,      __UpperCamelCase				):

      # avoid divided by 0 during interpolation
      if sorted_collection[left] == sorted_collection[right]:
            if sorted_collection[left] == item:
                  return left
            else:
                  return None

      SCREAMING_SNAKE_CASE_          =  left + ((item - sorted_collection[left]) * (right - left)) // (
          sorted_collection[right] - sorted_collection[left]
      )

      # out of range check
      if point < 0 or point >= len(__UpperCamelCase				):
            return None

      if sorted_collection[point] == item:
            return point
      elif point < left:
            return interpolation_search_by_recursion(__UpperCamelCase     ,      __UpperCamelCase     ,      __UpperCamelCase     ,      __UpperCamelCase				)
      elif point > right:
            return interpolation_search_by_recursion(__UpperCamelCase     ,      __UpperCamelCase     ,      __UpperCamelCase     ,      __UpperCamelCase				)
      else:
            if sorted_collection[point] > item:
                  return interpolation_search_by_recursion(
                      __UpperCamelCase     ,      __UpperCamelCase     ,      __UpperCamelCase     ,      point - 1				)
            else:
                  return interpolation_search_by_recursion(
                      __UpperCamelCase     ,      __UpperCamelCase     ,      point + 1     ,      __UpperCamelCase				)


def      a__ (		__UpperCamelCase				):
      if collection != sorted(__UpperCamelCase				):
            raise ValueError("Collection must be ascending sorted"				)
      return True


if __name__ == "__main__":
      import sys
      A     :  Any					     = 0
      if debug == 1:
            A     :  Any					     = [10, 30, 40, 45, 50, 66, 77, 93]
            try:
                  __assert_sorted(collection)
            except ValueError:
                  sys.exit("Sequence must be ascending sorted to apply interpolation search")
            A     :  int					     = 67

      A     :  List[str]					     = interpolation_search(collection, target)
      if result is not None:
            print(f"{target} found at positions: {result}")
      else:
            print("Not found")



from collections.abc import Callable


def      a__ (		__UpperCamelCase     ,      __UpperCamelCase     ,      __UpperCamelCase				):
      SCREAMING_SNAKE_CASE_          =  a
      SCREAMING_SNAKE_CASE_          =  b
      if function(__UpperCamelCase				) == 0:  # one of the a or b is a root for the function
            return a
      elif function(__UpperCamelCase				) == 0:
            return b
      elif (
          function(__UpperCamelCase				) * function(__UpperCamelCase				) > 0
      ):  # if none of these are root and they are both positive or negative,
            # then this algorithm can't find the root
            raise ValueError("could not find root in given interval."				)
      else:
            SCREAMING_SNAKE_CASE_          =  start + (end - start) / 2.0
            while abs(start - mid				) > 1_0**-7:  # until precisely equals to 10^-7
                  if function(__UpperCamelCase				) == 0:
                        return mid
                  elif function(__UpperCamelCase				) * function(__UpperCamelCase				) < 0:
                        SCREAMING_SNAKE_CASE_          =  mid
                  else:
                        SCREAMING_SNAKE_CASE_          =  mid
                  SCREAMING_SNAKE_CASE_          =  start + (end - start) / 2.0
            return mid


def      a__ (		__UpperCamelCase				):
      return x**3 - 2 * x - 5


if __name__ == "__main__":
      print(bisection(f, 1, 10_00))

      import doctest

      doctest.testmod()


