human
Give me a code to floor value Kth root of a number using Recursive Binary Search and the other steps required given the following:
Floor value Kth root of a number using Recursive Binary Search | Function to calculate x raised to the power y in O ( logn ).
Function to find the Kth root of the number N using BS.
If the range is still valid.
Find the mid - value of range.
Base Case.
Condition to check if the left search space is useless.
Given N and K.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to floor value Kth root of a number using Recursive Binary Search and the other steps required.
 def power ( x , y ) :
	if ( y == 0 ) :
		return 1 ;
	temp = power ( x , y // 2 ) ;
	if ( y % 2 == 0 ) :
		return temp * temp ;
	else :
		return x * temp * temp ;
def nthRootSearch ( low , high , N , K ) :
	if ( low <= high ) :
		mid = ( low + high ) // 2 ;
		if ( ( power ( mid , K ) <= N ) and ( power ( mid + 1 , K ) > N ) ) :
			return mid ;
		elif ( power ( mid , K ) < N ) :
			return nthRootSearch ( mid + 1 , high , N , K ) ;
		else :
			return nthRootSearch ( low , mid - 1 , N , K ) ;
	return low ;
N = 16 ; K = 4 ;
print ( nthRootSearch ( 0 , N , N , K ) )