Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def verifica(A,B):
- return verificaRic(A,B,0)
- def verificaRic(A,B,n):
- if isnull(A) or isnull(B):
- return False
- if controlloNodoLivello(info(A),B,n,0) == True:
- return True
- else:
- return verificaRic(left(A),B,n+1) or verificaRic(right(A),B,n+1)
- def controlloNodoLivello(info,Albero,maxLiv,livCorrente):
- if isnull(Albero):
- return False
- if livCorrente < maxLiv:
- if info = info(Albero):
- return True
- else:
- return controlloNodoLivello(info,left(Albero), maxLiv, livCorrente + 1) or controlloNodoLivello(info,right(Albero), maxLiv, livCorrente + 1)
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement