Question DSA-TREE-0036
EasyWhat is the output of this code?
class N:
def __init__(self, v, l=None, r=None):
self.v, self.l, self.r = v, l, r
def h(t):
return 0 if t is None else 1 + max(h(t.l), h(t.r))
print(h(N(1, N(2, N(4)), N(3))))
- A.
1
- B.
4
- C.
2
- D.
3
Sign up free to see the answer and a step-by-step explanation.