/TreeTraversal

Implementation of basic tree traversal algorithms

Primary LanguageJavaScript

TreeTraversal

Implementation of basic tree traversal iterative and recursive algorithms.

Example

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);

Notes and References