#include <stdio.h>
#include <stdlib.h>
typedef struct arbre{
int entier;
struct arbre* fg;
struct arbre* fd;
} Arbre;
Arbre* creation_arbre(int e){
Arbre* n = malloc(sizeof(Arbre));
if(n==NULL){ exit(1); }
n->entier = e;
n->fg = NULL;
n->fd = NULL;
return n;
}
Arbre* insertionABR(Arbre* a, int e){
if(a == NULL){ return creation_arbre(e); }
if(a->entier > e){
a->fg = insertionABR(a->fg,e);
} else {
a->fd = insertionABR(a->fd,e);
}
return a;
}
int recherhe(Arbre* a, int e, int somme){
if(a == NULL){
printf("L'élément recherché n'existe pas.");
return somme;
}
if(a->entier == e){
return somme+1;
}
if(a->entier > e){
return recherhe(a->fg, e, somme+1);
} else {
return 1 + recherhe(a->fd, e, somme+1);
}
}
int main() {
printf("Hello world!\n");
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: