Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean verifica(Albero A, Albero B) {
- if (trova(B, A.val) == true) {
- return true;
- }
- if (A.sinistro() == null && A.destro() == null ) {
- return false;
- }
- boolean flagSinistro = false;
- boolean flagDestro = false;
- if (A.sinistro() != null) {
- flagSinistro = verifica(A.sinistro(), B);
- }
- if (flagSinistro == true) {
- return true;
- }
- if (A.destro() != null) {
- flagDestro = verifica(A.destro(), B);
- }
- if (flagDestro == true) {
- return true;
- }
- return false;
- }
- public static boolean trova(Albero b, int valore) {
- if (b.val() == valore) {
- return true;
- }
- if (b.sinistro() == null && b.destro() == null ) {
- return false;
- }
- boolean flagSinistro = false;
- boolean flagDestro = false;
- if (b.sinistro() != null) {
- flagSinistro = trova(b.sinistro(), valore);
- }
- if (flagSinistro == true) {
- return true;
- }
- if (b.destro() != null) {
- flagDestro = trova(b.destro(), valore);
- }
- if (flagDestro == true) {
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment