Tree: Postorder Traversal

  • + 0 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 } `