human
Repeatedly search an element by doubling it after every successful search | Python program to repeatedly search an element by doubling it after every successful search.
Sort the given array so that binary search can be applied on it.
Maximum array element.
search for the element b present or not in array.
Driver code"
Solution in Python:

=====
Write me a code to repeatedly search an element by doubling it after every successful search and the other steps required?
assistant
#Here is code to repeatedly search an element by doubling it after every successful search and the other steps required.
 def binary_search ( a , x , lo = 0 , hi = None ) :
	if hi is None :
		hi = len ( a )
	while lo < hi :
		mid = ( lo + hi ) // 2
		midval = a [ mid ]
		if midval < x :
			lo = mid + 1
		elif midval > x :
			hi = mid
		else :
			return mid
	return - 1
def findElement ( a , n , b ) :
	a . sort ( )
	mx = a [ n - 1 ]
	while ( b < max ) :
		if ( binary_search ( a , b , 0 , n ) != - 1 ) :
			b *= 2
		else :
			return b
	return b
a = [ 1 , 2 , 3 ]
n = len ( a )
b = 1
print findElement ( a , n , b )