Implementation of basic tree traversal iterative and recursive algorithms.
var tree = [-1, 1, 2, 3, 4, 5, 6, 7];
console.log("inOrder");
inOrder_recursive(tree, 1);
console.log("-----");
inOrder_iterative(tree, 1);
console.log("-----");
console.log("preOrder");
preOrder_recursive(tree, 1);
console.log("-----");
preOrder_iterative(tree, 1);
console.log("-----");
console.log("postOrder");
postOrder_recursive(tree, 1);
console.log("-----");
postOrder_iterative(tree, 1);
- http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-introduction-to-algorithms-sma-5503-fall-2005/
- Cormen, T. (2009). Introduction to algorithms (3rd ed.). Cambridge, Mass.: MIT Press.
- https://en.wikipedia.org/wiki/Tree_traversal