Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean tuttiDiversiAlLivello(AlberoBin<Integer>a, int l){
- if (a==null)return false;
- AlberoBin<Integer> b = a;
- if (valoreTrovato(a.val(),l,0,b))
- return false;
- l++;
- if(a.sin()==null && a.des()== null)
- l=0;
- return tuttiDiversiAlLivello(a.sin(),l) && tuttiDiversiAlLivello(a.des(),l);
- }
- private static boolean valoreTrovato(Integer val, int livA, int livB, AlberoBin<Integer> b) {
- if(b==null)return false;
- if(livB !=0 && livA==livB && val == b.val())
- return true;
- livB++;
- if(b.sin()==null && b.des()==null)
- livB=0;
- return valoreTrovato(val,livA,livB,b.sin()) && valoreTrovato(val,livA,livB,b.des());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement