Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class es2 {
- public static boolean diRicerca (Albero a) {
- boolean ricSinistra = true;
- boolean ricDestra = true;
- // se non ci sta figlio sinistro allora è true per forza!
- if (a.sinistro() != null) {
- if (a.sinistro().val < a.val()) {
- ricSinistra = diRicerca(a.sinistro());
- }
- else {
- return false;
- }
- }
- // se non ci sta figlio destro allora è true per forza!
- if (a.destro() != null) {
- if (a.destro().val > a.val()) {
- ricDestra = diRicerca(a.destro());
- }
- else {
- return false;
- }
- }
- return (ricSinistra && ricDestra);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment