Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var stack = new Stack();
- stack.push(tree.root);
- while (stack.size) {
- var node = stack.pop();
- console.log('Traversed node:', node);
- node.children.forEach(function(child) {
- stack.push(child);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement