mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Add binary search tree.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user