SHARE
TWEET

Untitled

a guest Jun 19th, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static boolean tuttiDiversiAlLivello(AlberoBin<Integer>a, int l){
  2.         if (a==null)return false;
  3.         AlberoBin<Integer> b = a;
  4.         if (valoreTrovato(a.val(),l,0,b))
  5.             return false;
  6.         l++;
  7.         if(a.sin()==null && a.des()== null)
  8.             l=0;
  9.         return tuttiDiversiAlLivello(a.sin(),l) && tuttiDiversiAlLivello(a.des(),l);
  10.     }
  11.     private static boolean valoreTrovato(Integer val, int livA, int livB, AlberoBin<Integer> b) {
  12.         if(b==null)return false;
  13.         if(livB !=0 && livA==livB && val == b.val())
  14.             return true;
  15.         livB++;
  16.         if(b.sin()==null && b.des()==null)
  17.             livB=0;
  18.         return valoreTrovato(val,livA,livB,b.sin()) && valoreTrovato(val,livA,livB,b.des());
  19.     }
RAW Paste Data
Top