Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. var stack = new Stack();
  2. stack.push(tree.root);
  3.  
  4. while (stack.size) {
  5. var node = stack.pop();
  6. console.log('Traversed node:', node);
  7.  
  8. node.children.forEach(function(child) {
  9. stack.push(child);
  10. });
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement