Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def somma_liv_pari(A):
- return aux(A,0)
- def aux(A,livello):
- if A is None:
- return 0
- if A.sx is None and A.dx is None:
- if livello % 2 == 0:
- return A.val
- return 0
- somma = 0
- if livello % 2 == 0:
- somma = A.val
- if A.sx is not None:
- somma += aux(a.sx,livello + 1)
- if A.dx is not None:
- somma += aux(a.dx,livello + 1)
- return somma
Advertisement
Add Comment
Please, Sign In to add comment