def recursiveBinarySearch(L, k, left, right): print left, right # Base case if left > right: return False # Recursive cases mid = (left + right)/2 if k == L[mid]: return True if k < L[mid]: return recursiveBinarySearch(L, k, left, mid-1) if k > L[mid]: return recursiveBinarySearch(L, k, mid+1, right) # Main program L = [3, 5, 13, 18, 18, 27, 34, 56, 57, 60, 89] if recursiveBinarySearch(L, 13, 0, len(L)-1): print "Found the element." else: print "Did not find the element."