Advertisement
Davencode

Untitled

Sep 16th, 2021
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. ALGO(T,k)
  2. ST=LAST=ST_A=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. else
  17. st=push(st,ct)
  18. ct=ct->dx
  19. else
  20. ct=top(st)
  21. if(ct->key<k)then //se tale if fosse vero entrerei nella I chiamata ricorsiva
  22. b=val
  23. else if(ct->key>k)then
  24. a=val
  25. sta=push(sta,a)
  26. b=ct
  27. else
  28. if(last!=ct->sx && ct->sx!=NIL)then
  29. a=val
  30. sta=push(sta,a)
  31. ct=ct->sx
  32. else
  33. if(ct->sx=NIL)then
  34. a=val
  35. b=NIL
  36. else
  37. a=top(sta)
  38. pop(sta)
  39. b=val
  40. ret=BEST(a,b,k)
  41. + uscita dall'algoritmo
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement