You are viewing a single comment's thread. Return to all comments →
Solution with Javascript:
function postOrder(root) { const stack = iterate(root)
console.log(stack.join(' ')) }
function iterate(root, stack = []) { if (root == null) { return }
iterate(root.left, stack) iterate(root.right, stack)
stack.push(root.data)
return stack } `
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 →
Solution with Javascript:
function postOrder(root) { const stack = iterate(root)
console.log(stack.join(' ')) }
function iterate(root, stack = []) { if (root == null) { return }
iterate(root.left, stack) iterate(root.right, stack)
stack.push(root.data)
return stack } `