You are viewing a single comment's thread. Return to all comments →
this.levelOrder = function(root) { if (!root) { return; } const queue = []; queue.push(root); while (queue.length > 0) { const node = queue.shift(); process.stdout.write(node.data + " "); if (node.left) { queue.push(node.left); } if (node.right) { queue.push(node.right); } } };
Seems like cookies are disabled on this browser, please enable them to open this website
Day 23: BST Level-Order Traversal
You are viewing a single comment's thread. Return to all comments →
JavaSCript