You are viewing a single comment's thread. Return to all comments →
Very Simple Recursive JavaScript Solution:
const resp = []
function helperFunc(root) { if(!root) return; resp.push(root.data) helperFunc(root.right); helperFunc(root.left); }
function postOrder(root) { helperFunc(root); console.log(resp.reverse().join(' ')); }
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 →
Very Simple Recursive JavaScript Solution:
const resp = []
function helperFunc(root) { if(!root) return; resp.push(root.data) helperFunc(root.right); helperFunc(root.left); }
function postOrder(root) { helperFunc(root); console.log(resp.reverse().join(' ')); }