Add binary search tree.

This commit is contained in:
Oleksii Trekhleb
2018-04-03 07:50:30 +03:00
parent b89e406444
commit 1c911aadf0
4 changed files with 22 additions and 4 deletions

View File

@@ -1,17 +1,20 @@
export default class BinaryTreeNode {
constructor(value = null) {
constructor(value = null, parent = null) {
this.left = null;
this.right = null;
this.parent = parent;
this.value = value;
}
setLeft(node) {
this.left = node;
this.left.parent = this;
return this;
}
setRight(node) {
this.right = node;
this.right.parent = this;
return this;
}