You are viewing a single comment's thread. Return to all comments →
def height(root): if root == None: return(-1) else: return(ht(root)) def ht(node): if node != None: ldepth = height(node.left) rdepth = height(node.right) if ldepth > rdepth: return ldepth+1 else: return rdepth+1 else: return (0)
Tree: Height of a Binary Tree
You are viewing a single comment's thread. Return to all comments →
def height(root): if root == None: return(-1) else: return(ht(root)) def ht(node):
if node != None: ldepth = height(node.left) rdepth = height(node.right) if ldepth > rdepth: return ldepth+1 else: return rdepth+1
else: return (0)