Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean SottoAlberi(Albero A, Albero B) {
- int sommaA = somma(A.sinistro());
- int sommaB = somma(B.destro());
- if (sommaA == sommaB) {
- return true;
- }
- else {
- return false;
- }
- }
- public static int somma(Albero L) {
- if (L.sinistro() == null && L.destro() == null) { // passo base, รจ foglia!
- return L.val();
- }
- int conta = 0;
- if (L.sinistro != null) {
- conta += somma(L.sinistro());
- }
- if (L.destro != null) {
- conta += somma(L.destro());
- }
- return conta;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement