Davencode

Untitled

Sep 21st, 2021 (edited)
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. ALGOIT(T,k)
  2. ST=STA=LAST=NIL
  3. CT=T
  4. while(ct!=NIL || st!=NIL)do
  5. if(ct!=NIL)then
  6. a=NIL
  7. b=NIL
  8. if(ct->key < k)then
  9. a=ct
  10. sta=push(sta,a)
  11. st=push(st,ct)
  12. ct=ct->dx
  13. else if(ct->key > k)then
  14. st=push(st,ct)
  15. ct=ct->sx
  16. b=ct
  17. else
  18. st=push(st,ct)
  19. ct=ct->dx
  20. else
  21. ct=top(st)
  22. if(ct->key < k)then
  23. top(sta)
  24. b=val
  25. ret=best(a,b,k)
  26. + uscita
  27. else if(ct->key > k)then
  28. a=val
  29. b=ct
  30. ret=best(a,b,k)
  31. + uscita
  32. else
  33. if(last!=ct->sx && ct->sx!=NIL)then
  34. a=val
  35. sta=push(sta,a)
  36. ct=ct->sx
  37. else
  38. if(ct->sx=NIL)then
  39. a=val
  40. b=NIL
  41. ret=best(a,b,k)
  42. + uscita
  43. else
  44. b=val
  45. ret=best(top(sta),b,k)
  46. + uscita
  47.  
  48.  
Add Comment
Please, Sign In to add comment