You are viewing a single comment's thread. Return to all comments →
JavaScript Iterative Solution:
function postOrder(root) { let str = ''; let current = root; let stack = []; while (current != null) { str = ' ' + current.data + str; if (current.left != null) { stack.push(current.left); } if (current.right != null) { stack.push(current.right); } current = stack.pop(); } process.stdout.write(str.substring(1)); }
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Postorder Traversal
You are viewing a single comment's thread. Return to all comments →
JavaScript Iterative Solution: