human
Check whether a given binary tree is perfect or not | Returns depth of leftmost leaf ..
This function tests if a binary treeis perfect or not . It basically checks for two things : 1 ) All leaves are at same level 2 ) All internal nodes have two children.
An empty tree is perfect.
If leaf node , then its depth must be same as depth of all other leaves ..
If internal node and one child is empty.
Left and right subtrees must be perfect ..
Wrapper over isPerfectRec ( ).
Helper class that allocates a new node with the given key and None left and right pointer ..
Driver Code"
Solution in Python:

=====
Write me a code to check whether a given binary tree is perfect or not and the other steps required?
assistant
#Here is code to check whether a given binary tree is perfect or not and the other steps required.
 def findADepth ( node ) :
	d = 0
	while ( node != None ) :
		d += 1
		node = node . left
	return d
def isPerfectRec ( root , d , level = 0 ) :
	if ( root == None ) :
		return True
	if ( root . left == None and root . right == None ) :
		return ( d == level + 1 )
	if ( root . left == None or root . right == None ) :
		return False
	return ( isPerfectRec ( root . left , d , level + 1 ) and isPerfectRec ( root . right , d , level + 1 ) )
def isPerfect ( root ) :
	d = findADepth ( root )
	return isPerfectRec ( root , d )
class newNode :
	def __init__ ( self , k ) :
		self . key = k
		self . right = self . left = None
if __name__ == ' _ _ main _ _ ' :
	root = None
	root = newNode ( 10 )
	root . left = newNode ( 20 )
	root . right = newNode ( 30 )
	root . left . left = newNode ( 40 )
	root . left . right = newNode ( 50 )
	root . right . left = newNode ( 60 )
	root . right . right = newNode ( 70 )
	if ( isPerfect ( root ) ) :
		print ( " Yes " )
	else :
		print ( " No " )