BUT2/DEV/DEV3.2/TP08_Arbres_suite/Q1Arbre.java

79 lines
1.8 KiB
Java
Raw Normal View History

2023-11-29 16:08:44 +01:00
import java.util.*;
public class Q1Arbre{
private Q1Noeud racine;
public Q1Arbre(){
this.racine = null;
}
public Q1Arbre(int clef){
this.racine = new Q1Noeud(clef);
}
public Q1Arbre(Q1Noeud racine){
this.racine = racine;
}
public void add(Q1Noeud newNoeud){
if (this.racine == null){
this.racine = newNoeud;
}
else{
this.racine.add(newNoeud);
}
}
public void add(int clef){
if (this.racine == null){
this.racine = new Q1Noeud(clef);
}
else{
this.racine.add(clef);
}
}
private Q1Noeud plusPetit(){
if (this.racine != null){
Q1Noeud minimum = this.racine;
while (minimum.getPetit() != null){
minimum = minimum.getPetit();
}
return minimum;
}
return this.racine;
}
private Q1Noeud plusGrand(){
if (this.racine != null){
Q1Noeud maximum = this.racine;
while (maximum.getPetit() != null){
maximum = maximum.getPetit();
}
return maximum;
}
return this.racine;
}
private Q1Noeud suivant(int clef){
if (this.racine != null){
Q1Noeud maximum = this.racine;
while (maximum.getPetit() != null){
maximum = maximum.getPetit();
}
return maximum;
}
return this.racine;
}
public void affichage(){
if (this.racine != null){
Q1Noeud plusPetit = this.racine;
while (plusPetit.getPetit() != null){
plusPetit = plusPetit.getPetit();
}
System.out.print(plusPetit);
while ()
}
}
}