Add binary search tree.

This commit is contained in:
Oleksii Trekhleb
2018-04-03 07:35:13 +03:00
parent ff2df770b8
commit c5bccffe36
4 changed files with 20 additions and 6 deletions

View File

@@ -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) {