* Add a value to the binary search tree if it does not already exist in the * tree. * * The complexity of this operation is on average O(log n), where n is the * number of values in the tree. In the worst case, the complexity is O(n). * * @example Inserting values into the tree
(value: T)
| 437 | * @returns `true` if the value was inserted, `false` if the value already exists in the tree. |
| 438 | */ |
| 439 | insert(value: T): boolean { |
| 440 | return !!this.#insertNode(BinarySearchNode, value); |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * Remove a value from the binary search tree if it exists in the tree. |