Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def A_Ex4(a,n):
- conta = contanodi(a,n,0)
- return conta
- def contanodi(a,n,livellocorrente):
- if a is None:
- return 0
- if livellocorrente == n:
- return 1
- if a.getLeftChild() is None and a.getRightChild() is None:
- return 0
- conta = 0
- if a.getLeftChild() is not None:
- conta += contanodi(a.getLeftChild(),n,livellocorrente + 1)
- if a.getRightChild() is not None:
- conta += contanodi(a.getRightChild(),n,livellocorrente + 1)
- return conta
Advertisement
Add Comment
Please, Sign In to add comment