Advertisement
Davencode

Untitled

Sep 20th, 2021
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. Algo(T,k)
  2. ST=STX=STRET=LAST=NIL
  3. CT=T
  4. while(ct!=NIL || st!=NIL)do
  5. if(ct!=NIL)then
  6. ret=inf
  7. x=ct->k%2
  8. st=stx=push()
  9. ct=ct->sx
  10. else
  11. ct=top(st); x=top(stx);
  12. if(last!=ct->dx && ct->dx!=NIL)then
  13. y=val
  14. if(x=k%2)then
  15. ret=0
  16. else
  17. ret=y
  18. stret=push(stret,ret)
  19. ct=ct->dx
  20. else
  21. if(ct->dx=NIL)then
  22. y=val
  23. if(x=k%2)then
  24. ret=0
  25. else
  26. ret=y
  27. z=inf/nil
  28. ret=min(ret,z)+1
  29. + uscita algoritmo
  30. else
  31. z=val
  32. ret=min(top(stret),z)+1
  33. + uscita algoritmo
  34. return ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement