import random def contains(x, quarry): """precondition: x is a list, quarry is an object postcondition: returns True if quarry is found in the list""" for item in x: if quarry == item: return True return False N = 0 def sorted_contains(x, quarry): #global N if len(x) == 0 or N> 5: return False if len(x) == 1: return x[0] == quarry n = len(x)//2 #N += 1 print(x) if quarry == x[n]: return True if quarry < x[n]: return sorted_contains(x[:n], quarry) if quarry > x[n]: return sorted_contains(x[n:], quarry) x = [3,5,6,8,54,22,2] print(contains(x, 8)) print(contains(x, 100)) print(sorted_contains(x, 8)) print(sorted_contains(x, 100))