Hello, can someone help me to find the issue in my code
I'm working with trees, using the following structure :
struct noeud
{
struct noeud *gauche;
struct noeud *droite;
int desequilibre;
int valeur;
};
typedef struct noeud* arbre;
I'm trying to implement a rotation function which turn
v1
/
v2 D2
/
G D1
into :
v2
/
G v1
/
D1 D2
and i wrote that :
arbre rotation_droite(arbre a){
/*Effectue la rotation droite de l'arbre a*/
if (a != NULL && a->gauche != NULL){
int d1prime = -1 + a->desequilibre - max(a->gauche->desequilibre, 0);
int d2prime = -1+ a->gauche->desequilibre + min(0, d1prime);
arbre D = a->droite;
a->droite = cree_feuille(a->valeur);
a->valeur = a->gauche->valeur;
a->droite->gauche = a->gauche->droite;
a->droite -> droite = D;
a->droite->desequilibre = d1prime;
a->desequilibre = d2prime;
}
return a;
}
However, i'm getting a segmentation error and i dont understand why.
If someone can help me . . .
Thank you very much !