human
Write me a code to number of Binary Search Trees of height H consisting of H + 1 nodes and the other steps required given the following:
Number of Binary Search Trees of height H consisting of H + 1 nodes | Function to calculate x ^ y modulo 1000000007 in O ( log y ).
Stores the value of x ^ y.
Update x if it exceeds mod.
If x is divisible by mod.
If y is odd , then multiply x with result.
Divide y by 2.
Update the value of x.
Return the value of x ^ y.
Function to count the number of of BSTs of height H consisting of ( H + 1 ) nodes.
Driver Code"
Solution in Python:
assistant
#Here is code to number of Binary Search Trees of height H consisting of H + 1 nodes and the other steps required.
 def power ( x , y ) :
	mod = 1000000007
	res = 1
	x = x % mod
	if ( x == 0 ) :
		return 0
	while ( y > 0 ) :
		if ( y & 1 ) :
			res = ( res * x ) % mod
		y = y >> 1
		x = ( x * x ) % mod
	return res
def CountBST ( H ) :
	return power ( 2 , H )
H = 2
print ( CountBST ( H ) )