blob: 8eeddd26a371617fdc5a6ba403ec73b4ccb11f0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def max_height(node):
if node is None:
return 0 ;
else :
left_height = max_height(node.left)
right_height = max_height(node.right)
if (left_height > right_height):
return left_height+1
else:
return right_height+1
|