human
Count BST subtrees that lie in given range | A utility function to check if data of root is in range from low to high.
A recursive function to get count of nodes whose subtree is in range from low to high . This function returns true if nodes in subtree rooted under ' root ' are in range ..
Base case.
Recur for left and right subtrees.
If both left and right subtrees are in range and current node is also in range , then increment count and return true.
A wrapper over getCountUtil ( ) . This function initializes count as 0 and calls getCountUtil ( ).
Utility function to create new node.
Driver Code.
Let us construct the BST shown in the above figure.
Let us constructed BST shown in above example 10 / \ 5 50 / / \ 1 40 100"
How can the above be solved in Python?

Give me a code to count BST subtrees that lie in given range and the other steps required?
assistant
#Here is code to count BST subtrees that lie in given range and the other steps required.
 def inRange ( root , low , high ) :
	return root . data >= low and root . data <= high
def getCountUtil ( root , low , high , count ) :
	if root == None :
		return True
	l = getCountUtil ( root . left , low , high , count )
	r = getCountUtil ( root . right , low , high , count )
	if l and r and inRange ( root , low , high ) :
		count [ 0 ] += 1
		return True
	return False
def getCount ( root , low , high ) :
	count = [ 0 ]
	getCountUtil ( root , low , high , count )
	return count
class newNode :
	def __init__ ( self , data ) :
		self . data = data
		self . left = None
		self . right = None
if __name__ == ' _ _ main _ _ ' :
	root = newNode ( 10 )
	root . left = newNode ( 5 )
	root . right = newNode ( 50 )
	root . left . left = newNode ( 1 )
	root . right . left = newNode ( 40 )
	root . right . right = newNode ( 100 )
	l = 5
	h = 45
	print ( " Count ▁ of ▁ subtrees ▁ in ▁ [ " , l , " , ▁ " , h , " ] ▁ is ▁ " , getCount ( root , l , h ) )