mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-12-08 19:06:00 +00:00
Add binary search tree.
This commit is contained in:
parent
fbfdce030e
commit
8caf3a2201
@ -28,8 +28,10 @@ export default class BinarySearchTreeNode extends BinaryTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value < this.value && this.left) {
|
if (value < this.value && this.left) {
|
||||||
|
// Check left nodes.
|
||||||
return this.left.contains(value);
|
return this.left.contains(value);
|
||||||
} else if (this.right) {
|
} else if (this.right) {
|
||||||
|
// Check right nodes.
|
||||||
return this.right.contains(value);
|
return this.right.contains(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user