class Knoten  // ---------------------------------------
{  int inhalt;
   Knoten links, rechts;
   Knoten (int wert)
   { this.inhalt = wert;  this.links = null;  this.rechts = null; }
} // class Knoten

class BinaerBaum // ------------------------------------
{ Knoten wurzel = null;

  void rekFuegeEin (Knoten ast, int wert)
  { if (wert < ast.inhalt)
         { // links einfuegen
           if (ast.links == null)
                ast.links = new Knoten(wert);
           else rekFuegeEin(ast.links, wert);
         }
    else { // rechts einfuegen
           if (ast.rechts == null)
                ast.rechts = new Knoten(wert);
           else rekFuegeEin(ast.rechts, wert);
         }
  } // rekFuegeEin

  void fuegeEin (int wert)
  { if (wurzel == null)
         wurzel = new Knoten(wert);
    else rekFuegeEin(wurzel, wert);
  } // FuegeEin

  void rekLaufeDurch (Knoten ast)
  { if (ast != null)
         { rekLaufeDurch (ast.links);
           Out.print(ast.inhalt); Out.println();
           rekLaufeDurch (ast.rechts);
         }
  } // rekLaufeDurch

  void laufeDurch ()
  { if (wurzel != null)
         { rekLaufeDurch (wurzel.links);
           Out.print(wurzel.inhalt); Out.println();
           rekLaufeDurch (wurzel.rechts);
         }
  } // laufeDurch
} // class BinaerBaum

class BinBaumBsp0 // ----------------------------------
{ static BinaerBaum baum;

  public static void main(String[] arg)
  { int zahl = 0;
    String muell;
    baum = new BinaerBaum();
    Out.print("Bitte Zahlen eingeben. Ende mit -1."); Out.println();
    while (zahl != -1)
    { Out.print("Bitte Zahl eingeben: ");
      zahl = In.readInt();   muell = In.readLine();
      if (zahl != -1) baum.fuegeEin(zahl);
    } // while
    baum.laufeDurch();
  } // main
} // class BinBaumBsp0
