Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- deleteIter(T,K){
- tree* P=NULL;
- tree* curr=T;
- tree* Y =NULL;
- tree* X =NULL;
- while(curr!=NULL && curr->key!=K) //non so precisamente dove finisca questo while penso prenda tutto perΓ²
- P=curr;
- if (curr->key<k)
- curr=curr->Dx;
- else
- curr=curr->Sx;
- if(curr=NIL)
- return T;
- else {
- if (curr->Sx ==NULL || curr ->Dx == NULL)
- Y=curr;
- else{
- Y=curr->Dx;
- P=curr;
- while(Y->Sx==NULL){
- P=Y;
- Y=Y->Sx;
- }
- }
- }
- if(Y->Sx==NIL)
- X=Y->Dx;
- else
- X=Y->Sx;
- if(P==NULL)
- T=X;//dovrebbe essere l'assegnazione chiave
- else {
- if(Y=P->Sx)
- P->Sx=X;
- else
- P->Dx=X;
- }
- if(curr != Y){
- "copia Y in curr";
- "dealloca(Y)";
- }
- return T;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement