Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String toStringIterativePostorder(BSTNode<T> t) {
- String salida = "";
- Stack <BSTNode<T>> pila = new ALStack<BSTNode<T>>();
- pila.push(null);
- Stack<Boolean> izquierdo = new ALStack <Boolean>();
- BSTNode<T> act = root;
- while (act != null) {
- while (act != null) {
- pila.push(act);
- izquierdo.push(true);
- if (act.right != null) {
- pila.push(act.right);
- izquierdo.push(false);
- }
- act = act.left;
- }
- act = pila.pop();
- while (act != null && izquierdo.pop()) {
- salida += act.nodeValue + " ";
- act = pila.pop();
- }
- }
- return salida;
- }
Add Comment
Please, Sign In to add comment