cecema

Untitled

Jan 19th, 2018
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. Algo_IT(T,P,x){
  2. curr=T;
  3. last=NIL;
  4. ret=0;
  5. stack_curr=NIL;
  6. stack_a=NIL;
  7. a=0;
  8. b=0;
  9. push(stack_curr,P); //Stesso ragionamento per ES 2 TRACCIA 07/17 TRACCIA 1
  10. while(curr!=NIL || top(stack_curr){ // N.B. CORRETTO DA BENNI A RICEVIMENTO!
  11. if(curr!=NIL){
  12. push(stack_curr,curr);
  13. curr=curr->sx;
  14. ret=0;
  15. }else{
  16. curr=top(stack_curr);
  17. if(curr->dx!=NIL && curr->dx!=last){
  18. a=ret;
  19. push(stack_a,a);
  20. curr=curr->dx;
  21. ret=0;
  22. }else{
  23. POP(stack_curr);
  24. P=top(stack_curr);
  25. if(curr->dx!=NIL){
  26. a=top(stack_a);
  27. POP(stack_a);
  28. b=ret;
  29. }else{
  30. a=ret;
  31. b=0;
  32. }
  33. ret=a+b+1;
  34. if(P!=NIL && curr->key%2==0 && ret<x){
  35. last=curr;
  36. if(P->sx==curr)
  37. P->sx=Cancella_Radice(curr);
  38. else
  39. P->dx=Cancella_Radice(curr);
  40.  
  41. }else
  42. last=curr;
  43. }
  44. curr=NIL;
  45. }
  46. }
  47. return ret;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment