You are viewing a single comment's thread. Return to all comments →
JavaScript solution using recursion
function preOrder(root) { let res = ''; function abc(root){ if(root){ res = res + root.data + ' '; abc(root.left); abc(root.right) } } abc(root); console.log(res) }
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Preorder Traversal
You are viewing a single comment's thread. Return to all comments →
JavaScript solution using recursion