Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. //STACK: T,x
  2. Dubbi: ri-pushare x nello stack dopo aver fatto x=a+x
  3. al rigo 6, quando ct->sx=NIL, y sarΓ  uguale a 1?
  4.  
  5. ALGO (T) {
  6. st,sx=NIL;
  7. ct=T;
  8. lt=NIL;
  9. ritorno=NIL
  10. WHILE (ct!=NIL || st!=NIL) DO
  11. IF (ct!=NIL) THEN
  12. ret=1;
  13. x=ct->key%2;
  14. st=PUSH(st,t);
  15. sx=PUSH(sx,x);
  16. ct=ct->dx;
  17. ELSE
  18. st=TOP(st);
  19. sx=TOP(sx);
  20. IF (lt=ct->dx) THEN
  21. a=ritorno;
  22. x=a+x;
  23. sx=POP(sx);
  24. sx=PUSH(sx,x);
  25. IF (ct->sx!=NIL) THEN
  26. ct=ct->sx;
  27. ELSE
  28. y=1;
  29. ret=x*y*ct->key;
  30. st=POP(st);
  31. sx=POP(sx);
  32. lt=ct;
  33. ct=NIL;
  34. ritorno=ret;
  35. ELSE //lt=ct->sx
  36. y=ritorno;
  37. ret=x*y*ct->key;
  38. st=POP(st);
  39. sx=POP(sx);
  40. lt=ct;
  41. ct=NIL;
  42. ritorno=ret;
  43. return ret;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement