human
Check if each internal node of a BST has exactly one child | Check if each internal node of BST has only one child approach 2.
Initialize min and max using last two elements.
Every element must be either smaller than min or greater than max.
Driver program to test above function"
Solution in Python:
assistant
#Here is code to check if each internal node of a BST has exactly one child and the other steps required.
 def hasOnlyOneChild ( pre , size ) :
	min = 0 ; max = 0
	if pre [ size - 1 ] > pre [ size - 2 ] :
		max = pre [ size - 1 ]
		min = pre [ size - 2 ]
	else :
		max = pre [ size - 2 ]
		min = pre [ size - 1 ]
	for i in range ( size - 3 , 0 , - 1 ) :
		if pre [ i ] < min :
			min = pre [ i ]
		elif pre [ i ] > max :
			max = pre [ i ]
		else :
			return False
	return True
if __name__ == " _ _ main _ _ " :
	pre = [ 8 , 3 , 5 , 7 , 6 ]
	size = len ( pre )
	if ( hasOnlyOneChild ( pre , size ) ) :
		print ( " Yes " )
	else :
		print ( " No " )