Advertisement
Guest User

Asd-Esercizio2-giugno2017-traccia1

a guest
Nov 14th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. Algo_it(T,a,b)
  2.  
  3. ct=T;
  4. last=nil;
  5. stack_t=nil;
  6. while(ct!=nil or stack_t!=nil)do
  7. if (ct!=nil)then
  8. if (ct->key < a)then
  9. push(stack_t,ct);
  10. ct=ct->sx;
  11. else if(ct->key > b)then
  12. push(stack_t,ct);
  13. ct=ct->dx;
  14. else
  15. push(stack_t,ct);
  16. ct=ct->sx;
  17. else
  18. ct=top(stack_t)
  19. if (last!=ct->dx)then
  20. ct->sx=ret;
  21. if(ct->key <a)then
  22. pop(stack_t);
  23. last=ct;
  24. ct=nil;
  25. else
  26. if(ct->dx!=nil)then
  27. ct=ct->dx;
  28. else
  29. ct=cancella_root(ct)
  30. pop(stack_t);
  31. last=ct;
  32. ct=nil;
  33. else
  34. ct->dx=ret
  35. if(ct->key > b)then
  36. pop(stack_t);
  37. last=ct;
  38. ct=nil;
  39. else
  40. ct=cancella_root(ct)
  41. pop(stack_t);
  42. last=ct;
  43. ct=nil;
  44. return ct;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement