mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-12-19 08:59:05 +08:00
37 lines
554 B
JavaScript
37 lines
554 B
JavaScript
import BinarySearchTreeNode from './BinarySearchTreeNode';
|
|
|
|
export default class BinarySearchTree {
|
|
constructor() {
|
|
this.root = new BinarySearchTreeNode();
|
|
}
|
|
|
|
/**
|
|
* @param {*} value
|
|
*/
|
|
insert(value) {
|
|
this.root.insert(value);
|
|
}
|
|
|
|
/**
|
|
* @param {*} value
|
|
* @return {boolean}
|
|
*/
|
|
contains(value) {
|
|
return this.root.contains(value);
|
|
}
|
|
|
|
/**
|
|
* @param {*} value
|
|
*/
|
|
remove(value) {
|
|
return this.root.remove(value);
|
|
}
|
|
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
toString() {
|
|
return this.root.toString();
|
|
}
|
|
}
|