def contains(x, quarry): """precondition: x is a list, quarry is an object postcondition: returns True if quarry is found in the list""" for k in x: if quarry == k: return True return False def sorted_contains(x, quarry): """prec x is a SORTED list. (homogeneous) postc: return Tru if quarry is presnet in x""" if len(x) == 0: return False if len(x) == 1: return x[0] == quarry n = len(x)//2 if x[n] == quarry: return True if x[n] < quarry: return sorted_contains(x[n:], quarry) else: return sorted_contains(x[:n], quarry) #x = list(range(2,200, 7)) #print(x) #print(sorted_contains(x, 51)) #print(sorted_contains(x, 52)) #print(sorted_contains(x, 200)) #print(sorted_contains(x, 191)) print(sorted_contains(range(10000000), 252))