Guest User

Untitled

a guest
Apr 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public String toStringIterativePostorder(BSTNode<T> t) {
  2. String salida = "";
  3. Stack <BSTNode<T>> pila = new ALStack<BSTNode<T>>();
  4. pila.push(null);
  5. Stack<Boolean> izquierdo = new ALStack <Boolean>();
  6. BSTNode<T> act = root;
  7. while (act != null) {
  8. while (act != null) {
  9. pila.push(act);
  10. izquierdo.push(true);
  11. if (act.right != null) {
  12. pila.push(act.right);
  13. izquierdo.push(false);
  14. }
  15. act = act.left;
  16. }
  17. act = pila.pop();
  18. while (act != null && izquierdo.pop()) {
  19. salida += act.nodeValue + " ";
  20. act = pila.pop();
  21. }
  22. }
  23. return salida;
  24. }
Add Comment
Please, Sign In to add comment