mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-02-04 10:33:51 +08:00
Add binary search tree.
This commit is contained in:
@@ -2,6 +2,11 @@ import BinaryTreeNode from '../BinaryTreeNode';
|
||||
|
||||
export default class BinarySearchTreeNode extends BinaryTreeNode {
|
||||
insert(value) {
|
||||
if (this.value === null) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value < this.value) {
|
||||
// Insert to the left.
|
||||
if (this.left) {
|
||||
|
||||
Reference in New Issue
Block a user