Ragazzi io l'ho fatta in 10 minuti e non ho il tempo di implementare il main x vedere se funziona o meno... ve lo posto così come l'ho scritta ... sicuramente ci sarà qlk errore ma non credo sia irrisolvibile, fatemi sapere se funziona...
Ragazzi l'ho corretto, l'ho testato e pensate un po funziona...
Spoiler
[codice-c:ekx0xx65]#include "BTree.h"
#include
#include
TNode* ricerca_esami(TBst tree, char docente[]) {
TNode *l,*r;
if( Bst_is_empty(tree) )
return tree;
if (Bst_is_empty(tree->left)&& Bst_is_empty(tree->right)&&(strcmp(tree->info.satellite.docente,docente)==0))
return tree;
else
if( strcmp(tree->info.satellite.docente,docente)==0 ){
if( Bst_is_empty(tree -> left) ){
r = ricerca_esami( tree -> right, docente);
if( !Bst_is_empty® && (r -> info.satellite.voto > tree -> info.satellite.voto ))
return r;
else
return tree;
}else
if( Bst_is_empty(tree -> right) ){
l = ricerca_esami( tree -> left, docente);
if( !Bst_is_empty(l) && (l -> info.satellite.voto > tree -> info.satellite.voto) )
return l;
else
return tree;
}else{
l = ricerca_esami(tree->left,docente);
r = ricerca_esami(tree->right,docente);
if( Bst_is_empty(l) ){//Controllo del maggiore tra il nodo e il figlio destro
if( tree -> info.satellite.voto > r -> info.satellite.voto )
return tree;
else
return r;
}else if( Bst_is_empty® ){// Contollo del maggiore tra il nodo e il suo figlio sinistro
if( tree -> info.satellite.voto > l -> info.satellite.voto )
return tree;
else
return l;
}else{//Controllo x il calcolo del maggiore tra il nodo e i suoi figli
if( tree -> info.satellite.voto > l -> info.satellite.voto )
if( tree -> info.satellite.voto > r -> info.satellite.voto )
return tree;
else
return r;
else
if( l -> info.satellite.voto > r -> info.satellite.voto )
return l;
else
return r;
}
}
}else{
l = ricerca_esami( tree -> left, docente);
r = ricerca_esami( tree -> right, docente);
if( Bst_is_empty(l) )
if( Bst_is_empty® )
return NULL;
else
return r;
else
if( Bst_is_empty® )
return l;
else
if( r -> info.satellite.voto > l -> info.satellite.voto )
return r;
else
return l;
}
}[/codice-c]
#include
#include
TNode* ricerca_esami(TBst tree, char docente[]) {
TNode *l,*r;
if( Bst_is_empty(tree) )
return tree;
if (Bst_is_empty(tree->left)&& Bst_is_empty(tree->right)&&(strcmp(tree->info.satellite.docente,docente)==0))
return tree;
else
if( strcmp(tree->info.satellite.docente,docente)==0 ){
if( Bst_is_empty(tree -> left) ){
r = ricerca_esami( tree -> right, docente);
if( !Bst_is_empty® && (r -> info.satellite.voto > tree -> info.satellite.voto ))
return r;
else
return tree;
}else
if( Bst_is_empty(tree -> right) ){
l = ricerca_esami( tree -> left, docente);
if( !Bst_is_empty(l) && (l -> info.satellite.voto > tree -> info.satellite.voto) )
return l;
else
return tree;
}else{
l = ricerca_esami(tree->left,docente);
r = ricerca_esami(tree->right,docente);
if( Bst_is_empty(l) ){//Controllo del maggiore tra il nodo e il figlio destro
if( tree -> info.satellite.voto > r -> info.satellite.voto )
return tree;
else
return r;
}else if( Bst_is_empty® ){// Contollo del maggiore tra il nodo e il suo figlio sinistro
if( tree -> info.satellite.voto > l -> info.satellite.voto )
return tree;
else
return l;
}else{//Controllo x il calcolo del maggiore tra il nodo e i suoi figli
if( tree -> info.satellite.voto > l -> info.satellite.voto )
if( tree -> info.satellite.voto > r -> info.satellite.voto )
return tree;
else
return r;
else
if( l -> info.satellite.voto > r -> info.satellite.voto )
return l;
else
return r;
}
}
}else{
l = ricerca_esami( tree -> left, docente);
r = ricerca_esami( tree -> right, docente);
if( Bst_is_empty(l) )
if( Bst_is_empty® )
return NULL;
else
return r;
else
if( Bst_is_empty® )
return l;
else
if( r -> info.satellite.voto > l -> info.satellite.voto )
return r;
else
return l;
}
}[/codice-c]
Se ci dovessero essere altri problemi bhè... mi arrendo... (almeno su qst problema)