var levelOrder = function(root) { if (!root) { return; }
let queue = []; queue.unshift(root);
while(queue.length > 0) { let pointNode = queue.pop(); console.log(pointNode.value);
if (pointNode.left) { queue.unshift(pointNode.left) }
if (pointNode.right) { queue.unshift(pointNode.right); } } }
var tree = new TreeNode(3); tree.left = new TreeNode(9); tree.right = new TreeNode(20); tree.right.left = new TreeNode(15); tree.right.right = new TreeNode(7);
let depth = maxDepth(tree); console.log("depth:"+depth);
console.log("pre order:"); preOrder(tree);
console.log("mid order:"); midOrder(tree)
console.log("post order:"); postOrder(tree)
console.log("pre order without recursion"); preOrderWithoutRescursion(tree);
console.log("mid order without recursion"); midOrderWithoutRescursion(tree);
console.log("post order without recursion"); postOrderWithoutRescursion(tree);