Advertisement
Giuliox

Traccia 18/07/17 tema1

Jan 10th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. Algo(T,k,P){
  2. St, Sp, Sir, Sh1, ret=-1;
  3. next, currT=T, currP=P, ir = 0;
  4. while(St != Nil or currT!=Nil){
  5. if ir = 0 then
  6. ret = -1
  7. if currT != Nil then
  8. push(St,currT)
  9. push(Sp,currp)
  10. push(Sir,0)
  11. next = currT->sx
  12. currP = currT
  13. ir=0
  14. else
  15. ir=top(Sir)
  16. pop(Sir)
  17. next = top(St)
  18. currP = top(Sp)
  19. if ir==0 then
  20. ir=1
  21. push(Sir,1)
  22. else if ir == 1 then
  23. ir=2
  24. push(Sir,2)
  25. else if ir == 1 then
  26. push(Sh1, ret)
  27. next = currT->dx
  28. currP= currT
  29. ir=0
  30. pop(Sir)
  31. push(Sir,1)
  32. else if ir == 2 then
  33. h2 = top(Sh1) + ret
  34. pop(Sh1)
  35. ret = h2+1
  36. if ret > k and currP!= Nil then
  37. if currT == currP->Dx then
  38. currP->Dx = CANCELLA_RADICE(currT)
  39. else
  40. currP->Sx = CANCELLA_RADICE(currT)
  41. pop(St)
  42. pop(Sp)
  43. pop(Sir)
  44. ir=Top(Sir)
  45. next=Top(St)
  46. currP = Top(Sp)
  47. if(ir == 0) then
  48. ir = 1
  49. else if (ir == 1) then
  50. ir = 2
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement