public class ArbreBinaireRecherche {

    Noeud root;

    public ArbreBinaireRecherche(int valeur) {
        this.root = new Noeud(valeur);
    }

    public ArbreBinaireRecherche() {}

    public void add(int val) {
        root = addRecursif(root, val);
    }

    public Noeud addRecursif(Noeud current, int val) {
        if (current == null) {
            return new Noeud(val);
        }
        if (val < current.getValeur()) {
            current.left = addRecursif(current.left, val);
        } else if (val > current.getValeur()) {
            current.right = addRecursif(current.right, val);
        } else {
            return current;
        }
        return current;
    }

    public void show() {
        System.out.println("Affichage de l'arbre binaire de recherche (ordre infixe) :");
        afficherInfixe(root);
        System.out.println();
    }

    private void afficherInfixe(Noeud current) {
        if (current != null) {
            afficherInfixe(current.left);
            System.out.print(current.getValeur() + " ");
            afficherInfixe(current.right);
        }
    }

    public String toString()
    {

        return "";
    }
}