public class Solmetest4{ //trükitakse väärtused vastavast sõlmest alates public static void trykiSolm(Solm s){ if(s==null){return;} System.out.print(s.sisu+" "); trykiSolm(s.vasak); trykiSolm(s.parem); } public static void main(String[] argumendid){ Solm s1=new Solm(); Solm s2=new Solm(); Solm s3=new Solm(); Solm s4=new Solm(); Solm s5=new Solm(); Solm s6=new Solm(); s1.sisu=4; s2.sisu=3; s3.sisu=8; s4.sisu=5; s5.sisu=7; s6.sisu=10; s1.vasak=s2; s1.parem=s3; s2.vasak=s4; s3.vasak=s5; s3.parem=s6; trykiSolm(s3); System.out.println(); trykiSolm(s1); } } /* 4 / \ 3 8 / / \ 5 7 10 C:\jaagup>java Solmetest4 8 7 10 4 3 5 8 7 10 */