Livelli
This commit is contained in:
@@ -57,6 +57,11 @@ class Nodo{
|
|||||||
else if(albero.dato==valore) return true;
|
else if(albero.dato==valore) return true;
|
||||||
else return trova(albero.left, valore) || trova(albero.right, valore);
|
else return trova(albero.left, valore) || trova(albero.right, valore);
|
||||||
}
|
}
|
||||||
|
static String valoriNelLivello(Nodo albero, int livello){
|
||||||
|
if(albero==null) return "";
|
||||||
|
else if(livello==0) return albero.dato + "";
|
||||||
|
else return valoriNelLivello(albero.left, livello-1) + valoriNelLivello(albero.right, livello-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user