davegimo

mimi

Nov 8th, 2020 (edited)
844
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def verifica(A,B):
  2.     return verificaRic(A,B,0)
  3.    
  4. def verificaRic(A,B,n):
  5.     if isnull(A) or isnull(B):
  6.         return False
  7.     if controlloNodoLivello(info(A),B,n,0) == True:
  8.         return True
  9.     else:
  10.         return verificaRic(left(A),B,n+1) or verificaRic(right(A),B,n+1)
  11.  
  12.  
  13. def controlloNodoLivello(info,Albero,maxLiv,livCorrente):
  14.     if isnull(Albero):
  15.         return False
  16.    
  17.     if livCorrente < maxLiv:
  18.         if info = info(Albero):
  19.             return True
  20.         else:
  21.             return controlloNodoLivello(info,left(Albero), maxLiv, livCorrente + 1) or controlloNodoLivello(info,right(Albero), maxLiv, livCorrente + 1)
  22.  
  23.     return False
  24.            
RAW Paste Data