import { Comparator } from './utils/comparator'; export declare class BinarySearchTree { private _root; private _size; private _comparator; /** * Creates a new instance of BinarySearchTree. * * @param comparator The comparator function to use. (Optional) */ constructor(comparator?: Comparator); /** * Inserts value into the tree. * * @param value The value to insert. * * @timeComplexity `O(log(n))` */ insert(value: T): void; /** * Deletes value from the tree. * * @param value The value to delete. * * @timeComplexity `O(log(n))` * * @returns The new successor node. This can also be `undefined` if * the deleted node doesn't have a successor or there was no deleted node. */ delete(value: T): BinarySearchTreeNode | undefined; /** * Deletes values that doesn't meet the filter function condition. * * @param filterFunction A function that decides which values to delete. * It should return `false` if the value needs to be deleted, * otherwise `true`. * * @timeComplexity `O(n + k * log(n))` where `k` is the number of values * that doesn't meet the filter function condition. * * @returns An array of values that has been deleted. */ filter(filterFunction: (value: T) => boolean): T[]; /** * Clears all elements from the tree. * * @timeComplexity `O(1)` */ clear(): void; /** * Clones the tree. * * @timeComplexity `O(n)` */ clone(): BinarySearchTree; /** * Converts the tree to a sorted array. * * @timeComplexity `O(n)` * * @returns An array representation of the tree. */ toArray(): T[]; /** * Finds the data with the smallest value in the tree. * * @timeComplexity `O(log(n))` * * @returns The minimum data or void if the tree is empty. */ min(): T | undefined; /** * Finds the data with the largest value in the tree. * * @timeComplexity `O(log(n))` * * @returns The maximum data or void if the tree is empty. */ max(): T | undefined; /** * Gets the size of the tree. * * @timeComplexity `O(1)` * * @returns The number of nodes in the tree. */ size(): number; /** * Checks if the tree is empty. * * @timeComplexity `O(1)` * * @returns True if the tree is empty, otherwise false. */ isEmpty(): boolean; /** * Gets the height of the tree. * * @timeComplexity `O(1)` * * @returns The height of the tree. */ height(): number; root(): BinarySearchTreeNode | undefined; values(): Generator; [Symbol.iterator](): Generator; /** * Creates an BinarySearchTree from an unsorted array of elements. * * @param array The array of elements to insert into the tree. * @param comparator The comparator function to use. (Optional) * * @timeComplexity `O(n * log(n))` * * @returns A new instance of BinarySearchTree. */ static fromArray(array: T[], comparator?: Comparator): BinarySearchTree; /** * Creates an BinarySearchTree from a sorted array of elements. * * @param array The array of elements to insert into the tree. * @param comparator The comparator function to use. (Optional) * * @timeComplexity `O(n)` * * @returns A new instance of BinarySearchTree. */ static fromSortedArray(array: T[], comparator?: Comparator): BinarySearchTree; } export declare class BinarySearchTreeNode { private _value; private _left; private _right; private _height; constructor(value: T); /** * Get the left child of the node. * * @timeComplexity `O(1)` */ left(): BinarySearchTreeNode | undefined; /** * Get the right child of the node. * * @timeComplexity `O(1)` */ right(): BinarySearchTreeNode | undefined; /** * Get the value of the node. * * @timeComplexity `O(1)` */ value(): T; /** * Get the height of the node. * * @timeComplexity `O(1)` */ height(): number; /** * Change the left child of the node. * * For internal use only. * * @timeComplexity `O(1)` */ setLeft(node: BinarySearchTreeNode | undefined): void; /** * Change the right child of the node. * * For internal use only. * * @timeComplexity `O(1)` */ setRight(node: BinarySearchTreeNode | undefined): void; /** * Change the height of the node. * * For internal use only. * * @timeComplexity `O(1)` */ setHeight(height: number): void; /** * Updates the height of the node. * * For internal use only. * * @timeComplexity `O(1)` */ updateHeight(): void; /** * Rotates the node to the left. * * For internal use only. * * @timeComplexity `O(1)` * * @returns The new successor. */ rotateLeft(): BinarySearchTreeNode; /** * Rotates the node to the right. * * For internal use only. * * @timeComplexity `O(1)` * * @returns The new successor. */ rotateRight(): BinarySearchTreeNode; /** * Compute the balance factor of the node. * * For internal use only. * * @timeComplexity `O(1)` * * @returns The balance factor. */ computeBalanceFactor(): number; /** * Balances the node. * * For internal use only. * * @timeComplexity `O(1)` * * @returns The new successor. */ balance(): BinarySearchTreeNode; }