human
Find Leftmost and Rightmost node of BST from its given preorder traversal | Function to return the leftmost and rightmost nodes of the BST whose preorder traversal is given.
Variables for finding minimum and maximum values of the array.
Update the minimum.
Update the maximum.
Print the values.
Driver Code"
Solution in Python:

=====
Write me a code to find Leftmost and Rightmost node of BST from its given preorder traversal and the other steps required?
assistant
#Here is code to find Leftmost and Rightmost node of BST from its given preorder traversal and the other steps required.
 def LeftRightNode ( preorder , n ) :
	min = 10 ** 9
	max = - 10 ** 9
	for i in range ( n ) :
		if ( min > preorder [ i ] ) :
			min = preorder [ i ]
		if ( max < preorder [ i ] ) :
			max = preorder [ i ]
	print ( " Leftmost ▁ node ▁ is ▁ " , min )
	print ( " Rightmost ▁ node ▁ is ▁ " , max )
preorder = [ 3 , 2 , 1 , 5 , 4 ]
n = len ( preorder )
LeftRightNode ( preorder , n )