Esempio n. 1
0
 def deepest_node(self,node):
     if node is None:
         return 0
     q=queue()
     q.enqueue(node)
     while q.is_empty()!=True:
         node=q.dequeue()
         if(node.left_node()!=None):
             q.enqueue(node.left_node())
         if(node.right_node()!=None):
             q.enqueue(node.right_node())
     return node.get_data()
 def leaf_nodes(self,node):
     if node is None:
         return 0
     q=queue()
     q.enqueue(node)
     count=0
     while q.is_empty()!=True:
         node=q.dequeue()
         if (node.left_node()==None and node.right_node()==None):
             count+=1
         if(node.left_node()!=None):
             q.enqueue(node.left_node())
         if(node.right_node()!=None):
             q.enqueue(node.right_node())
     return count