Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 91e3c95

Browse files
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

Lines changed: 2 additions & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /