Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Algo_IT(T,P,x){
- curr=T;
- last=NIL;
- ret=0;
- stack_curr=NIL;
- stack_a=NIL;
- a=0;
- b=0;
- push(stack_curr,P); //Stesso ragionamento per ES 2 TRACCIA 07/17 TRACCIA 1
- while(curr!=NIL || top(stack_curr){ // N.B. CORRETTO DA BENNI A RICEVIMENTO!
- if(curr!=NIL){
- push(stack_curr,curr);
- curr=curr->sx;
- ret=0;
- }else{
- curr=top(stack_curr);
- if(curr->dx!=NIL && curr->dx!=last){
- a=ret;
- push(stack_a,a);
- curr=curr->dx;
- ret=0;
- }else{
- POP(stack_curr);
- P=top(stack_curr);
- if(curr->dx!=NIL){
- a=top(stack_a);
- POP(stack_a);
- b=ret;
- }else{
- a=ret;
- b=0;
- }
- ret=a+b+1;
- if(P!=NIL && curr->key%2==0 && ret<x){
- last=curr;
- if(P->sx==curr)
- P->sx=Cancella_Radice(curr);
- else
- P->dx=Cancella_Radice(curr);
- }else
- last=curr;
- }
- curr=NIL;
- }
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment