human
Smallest element greater than X not present in the array | Function to return the smallest element greater than x which is not present in a [ ].
Sort the array.
Continue until low is less than or equals to high.
Find mid.
If element at mid is less than or equals to searching element.
If mid is equals to searching element.
Increment searching element.
Make high as N - 1.
Make low as mid + 1.
Make high as mid - 1.
Return the next greater element.
Driver code"
Solution in Python:
assistant
#Here is code to smallest element greater than X not present in the array and the other steps required.
 def Next_greater ( a , n , x ) :
	a = sorted ( a )
	low , high , ans = 0 , n - 1 , x + 1
	while ( low <= high ) :
		mid = ( low + high ) // 2
		if ( a [ mid ] <= ans ) :
			if ( a [ mid ] == ans ) :
				ans += 1
				high = n - 1
			low = mid + 1
		else :
			high = mid - 1
	return ans
a = [ 1 , 5 , 10 , 4 , 7 ]
x = 4
n = len ( a )
print ( Next_greater ( a , n , x ) )