human
Get maximum left node in binary tree | Get max of left element using Inorder traversal.
Return maximum of three values 1 ) Recursive max in left subtree 2 ) Value in left node 3 ) Recursive max in right subtree.
Utility class to create a new tree node.
Driver Code.
Let us create binary tree shown in above diagram.
7 / \ 6 5 / \ / \ 4 3 2 1"
How can the above be solved in Python?
 Write me a code to get maximum left node in binary tree and the other steps required?
assistant
#Here is code to get maximum left node in binary tree and the other steps required.
 def maxOfLeftElement ( root ) :
	res = - 999999999999
	if ( root == None ) :
		return res
	if ( root . left != None ) :
		res = root . left . data
	return max ( { maxOfLeftElement ( root . left ) , res , maxOfLeftElement ( root . right ) } )
class newNode :
	def __init__ ( self , data ) :
		self . data = data
		self . left = self . right = None
if __name__ == ' _ _ main _ _ ' :
	root = newNode ( 7 )
	root . left = newNode ( 6 )
	root . right = newNode ( 5 )
	root . left . left = newNode ( 4 )
	root . left . right = newNode ( 3 )
	root . right . left = newNode ( 2 )
	root . right . right = newNode ( 1 )
	print ( maxOfLeftElement ( root ) )