Advertisement
Davencode

Untitled

Jun 11th, 2021
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. Algo_IT(T,P,x)
  2.  
  3. ST=STA=STP=LAST=NIL
  4. CT=T ; CP = P;
  5. while(CT != NIL || ST != NIL) do
  6. if(CT != NIL) then
  7. ret = 0
  8. ST = push(ST,CT)
  9. STP = push(STP, CP)
  10. CT = CT->SX
  11. P = CT
  12. else //risalgo dalla prima chiamata ricorsiva riga 3
  13. CT = TOP (ST) ; CP = TOP(STP) ;
  14. if ( LAST =! CT->DX && CT->DX != NIL ) then
  15. a = val;
  16. STA = push(STA, A)
  17. CT=CT->DX
  18. P=CT
  19. else
  20. if (LAST = CT->DX) then
  21. b=val
  22. TOP(STA); POP(STA);
  23. ret = a+b+1
  24. else
  25. a=val
  26. b=0
  27. ret=a+b+1
  28. if(CT->Key%2 = 0 ^ ret < x ^ P != NIL) then
  29. if(CT=CP->DX)then
  30. CP->DX=cancella_radice(CT)
  31. else
  32. CP->SX=cancella_radice(CT)
  33. Pop(ST);Pop(STP);
  34. LAST = CT;
  35. CT = NIL;
  36. return ret;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement