Skip to content

Commit 91e3c95

Browse files
committed
Depth first traversal post order
1 parent d40c88a commit 91e3c95

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

binarySearchTree.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ BST.prototype.depthFirstTraversal = function(iteratorFunc, order) {
3636
if (this.left) this.left.depthFirstTraversal(iteratorFunc, order);
3737
if (order === "in-order") iteratorFunc(this.value);
3838
if (this.right) this.right.depthFirstTraversal(iteratorFunc, order);
39+
if (order === "post-order") iteratorFunc(this.value);
3940
};
4041

4142
let bst = new BST(50);
@@ -56,4 +57,4 @@ function log(value) {
5657
console.log(value);
5758
}
5859

59-
bst.depthFirstTraversal(log, "pre-order");
60+
bst.depthFirstTraversal(log, "post-order");

0 commit comments

Comments
 (0)