human
Check if ceil of number divided by power of two exist in sorted array | Function to find there exist a number or not in the array.
Loop to check if there exist a number by divided by power of 2.
Binary Search.
Condition to check the number is found in the array or not.
Otherwise divide the number by increasing the one more power of 2.
Driver Code"
Solution in Python:
assistant
#Here is code to check if ceil of number divided by power of two exist in sorted array and the other steps required.
 def findNumberDivByPowerofTwo ( ar , k , n ) :
	found = - 1
	m = k
	while ( m > 0 ) :
		l = 0
		r = n - 1
		while ( l <= r ) :
			mid = ( l + r ) // 2
			if ( ar [ mid ] == m ) :
				found = m
				break
			elif ( ar [ mid ] > m ) :
				r = mid - 1
			elif ( ar [ mid ] < m ) :
				l = mid + 1
		if ( found != - 1 ) :
			break
		m = m // 2
	return found
arr = [ 3 , 5 , 7 , 8 , 10 ]
k = 4
n = 5
print ( findNumberDivByPowerofTwo ( arr , k , n ) )