int f2(nodo *x, int *y,int *c,int top){
if(!x) return -1; //se l'albero è vuoto ritorno -1
if(x->info==y) return top;
if(x->left){
int sx=f2(x->left,y,c,top+1);
if(sx!=-1){
c[top]=0;
return sx;
}
}
if(x->right){
int dx=f2(x->right,y,c,top+1);
if(dx!=-1){
c[top]=1;
return dx;
}
}
return (-1);
} |
int f2(nodo *x, int *y,int *c,int top){
if(!x) return -1; //se l'albero è vuoto ritorno -1
if(x->info==y) return top;
if(x->left){
int sx=f2(x->left,y,c,top+1);
if(sx!=-1){
c[top]=0;
return sx;
}
}
if(x->right){
int dx=f2(x->right,y,c,top+1);
if(dx!=-1){
c[top]=1;
return dx;
}
}
return (-1);
}
Continua la lettura, ecco altri articoli interessanti: