Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Algo_it(T,P){
- ct=T;
- cp=P;
- last=nil;
- stack_t=stack_x=stack_flag=stack_p=nil;
- while(ct!=nil or stack_t!=nil)do
- if(ct!=nil)then
- flag=0;
- ret=0;
- if(ct->key % 2 = 0 )then
- flag=1;
- push(stack_t,ct);
- push(stack_p,cp);
- push(stack_flag,flag);
- ct=ct->sx;
- cp=ct;
- else
- cp=top(stack_p);
- ct=top(stack_t);
- falg=top(stack_flag);
- if (last!=ct->dx)then
- x=ret;
- if(ct->dx!=nil)then
- push(stack_x,x);
- ct=ct->dx;
- cp=ct;
- else
- y=0
- if(flag=1 AND cp!=nil AND x+y=0)then
- if(cp->sx=ct)then
- ct->sx=cancella_root(ct);
- else
- ct->dx=cancella_root(ct);
- ret=x+y+flag;
- pop(stack_t);
- pop(stack_p);
- pop(stack_x);
- pop(stack_flag);
- las=ct;
- ct=nil;
- else
- y=ret;
- x=top(stack_x);
- if(flag=1 AND cp!=nil AND x+y=0)then
- if(cp->sx=ct)then
- ct->sx=cancella_root(ct);
- else
- ct->dx=cancella_root(ct);
- ret=x+y+flag;
- pop(stack_t);
- pop(stack_x);
- pop(stack_flag);
- pop(stack_p);
- las=ct;
- ct=nil;
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement