Advertisement
Davencode

Untitled

Oct 23rd, 2021
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. ALGOIT(T,k,P)
  2. ST=STP=STH1=LAST=NIL
  3. CT=T
  4. while(ct!=NIL || st!=NIL)do
  5. if(ct!=NIL)then
  6. ret=-1
  7. st=push(st,ct)
  8. stp=push(stp,cp)
  9. CP=CT
  10. ct=ct->sx
  11. else
  12. ct=top(st); cp=top(stp)
  13. if(last!=ct->dx && ct->dx!=NIL)then
  14. h1=val
  15. sth1=push(sth1,h1)
  16. ct=ct->dx
  17. else
  18. if(ct->dx=NIL)then
  19. h1=val
  20. h2=h1-1
  21. ret=h2+1
  22. if(ret > k ^ cp!=NIL)then
  23. if(ct=cp->dx)then
  24. cp->dx=cancellaroot(ct)
  25. else
  26. cp->sx=cancellaroot(ct)
  27. +uscita algoritmo
  28. else
  29. top(sth1); pop(sth1)
  30. h2=h1+val
  31. ret=h2+1
  32. if(ret > k ^ cp!=NIL)then
  33. if(ct=cp->dx)then
  34. cp->dx=cancellaroot(ct)
  35. else
  36. cp->sx=cancellaroot(ct)
  37. +uscita algoritmo
  38. return ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement