public class Tri{

	private Noeud racine;

	public Tri(float f){
		this.racine = new Noeud(f);
	}

	public void ajouterNoeud(float f){
		if(this.racine.val>f){
			if(this.racine.noeudGauche==null){
				this.racine.addNoeudGauche(f);
			}
			else{
				this.ajouterNoeud(f,this.racine.noeudGauche);
			}
		}
		else{
			if(this.racine.noeudDroit==null){
				this.racine.addNoeudDroit(f);
			}
			else{
				this.ajouterNoeud(f,this.racine.noeudDroit);
			}
		}
	}

	public void ajouterNoeud(float f, Noeud n){
		if(n.val>f){
			if(n.noeudGauche==null){
				n.addNoeudGauche(f);
			}
			else{
				this.ajouterNoeud(f,n.noeudGauche);
			}
		}
		else{
			if(n.noeudDroit==null){
				n.addNoeudDroit(f);
			}
			else{
				this.ajouterNoeud(f,n.noeudDroit);
			}
		}
	}

	@Override
	public String toString(){
		String retour = "";
		if(this.racine.noeudGauche!=null){
			retour = toString(this.racine.noeudGauche) + retour;
		}
		if(this.racine.noeudDroit!=null){
			retour = retour + " " + toString(this.racine.noeudDroit);
		}
		return retour;
	}

	public String toString(Noeud n){
		String retour = " "+n.val;
		if(n.noeudGauche!=null){
			retour = toString(n.noeudGauche) + retour;
		}
		if(n.noeudDroit!=null){
			retour = retour + " " + toString(n.noeudDroit);
		}
		return retour;
	}
}