Tree: Height of a Binary Tree

  • + 0 comments

    def height(root): left = root.left right = root.right if left == None and right == None: return 0 r_ht, l_ht = 0, 0 if left!=None: l_ht = height(left) if right!=None: r_ht = height(right) return 1+max(r_ht,l_ht)