davegimo

es1AlberiPython

May 30th, 2020
202
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def sommaNodi(A):
  2.     if isNull(left(A)) and isNull(right(A)):  #nodo foglia --> passo base!
  3.         return info(A)
  4.    
  5.     somma = info(A)
  6.  
  7.     if not isNull(left(A)):
  8.         somma += sommaNodi(left(A))
  9.    
  10.     if not isNull(right(A)):
  11.         somma += sommaNodi(right(A))
  12.    
  13.     return somma
  14.  
  15. def sommaNodiPRO(A):
  16.     if isNull(A):
  17.         return 0
  18.     return info(A) + sommaNodiPRO(left(A)) + sommaNodiPRO(right(A))
RAW Paste Data