@cute-dw/core
Version:
This TypeScript library is the main part of a more powerfull package designed for the fast WEB software development. The cornerstone of the library is the **DataStore** class, which might be useful when you need a full control of the data, but do not need
45 lines (44 loc) • 1.55 kB
TypeScript
import { BinarySearchTree } from "./BinarySearchTree";
import { Element } from "../Collection";
import { BinaryTreeNode } from "./BinaryTreeNode";
/**
* In computer science, an `AVL tree` (named after inventors Adelson-Velsky and Landis) is a
* self-balancing binary search tree. It was the first such data structure to be invented.
* In an AVL tree, the heights of the two child subtrees of any node differ by at most one;
* if at any time they differ by more than one, rebalancing is done to restore this property.
* Lookup, insertion, and deletion all take O(log n) time in both the average and worst cases,
* where n is the number of nodes in the tree prior to the operation. Insertions and deletions
* may require the tree to be rebalanced by one or more tree rotations.
*/
export declare class AvlTree<K, V = K> extends BinarySearchTree<K, V> {
/**
* @param {K} key
* @param {Element} value
*/
add(key: K, value: Element<V>): BinaryTreeNode<K, V>;
/**
* @param {K} key
* @return {boolean}
*/
remove(key: K): Element<V> | undefined;
/**
* @param {BinaryTreeNode} node
*/
private balance;
/**
* @param {BinaryTreeNode} rootNode
*/
private rotateLeftLeft;
/**
* @param {BinaryTreeNode} rootNode
*/
private rotateLeftRight;
/**
* @param {BinaryTreeNode} rootNode
*/
private rotateRightLeft;
/**
* @param {BinaryTreeNode} rootNode
*/
private rotateRightRight;
}