Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Les prototypes
- arbre *creerFeuille(int x);
- arbre *ajouter(int x,arbre *arb);
- void explorer(arbre *arb);
- int recherche(int x,arbre *arb);
- arbre *supprimer(int x,arbre **arb);
- int profondeur(arbre *arb);
- //Les fonctions
- arbre* creerFeuille(char* x) {
- arbre *feuille =malloc(arbre);
- if (feuille !=NULL) {
- feuille->cle=x;
- feuille->gauche=NULL;
- feuille->droit=NULL;
- return feuille;
- }
- }
- arbre *ajouter(char x, arbre *arb) {
- if (arb==NULL) {
- arb=creerFeuille(x);
- }
- else {
- if(x<arb->cle)
- arb->gauche=ajouter(x,arb->gauche);
- else
- arb->droit=ajouter(x,arb->droit);
- }
- return arb;
- }
- void explorer(arbre *arb) {
- if (arb!=NULL) {
- explorer(arb->gauche);
- printf("%d\t",arb->cle);
- explorer(arb->droit);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement