red-black-tree-typed 1.53.7 → 1.54.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +52 -0
- package/dist/common/index.js +5 -0
- package/dist/data-structures/base/iterable-entry-base.js +4 -4
- package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
- package/dist/data-structures/binary-tree/avl-tree-counter.js +407 -0
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -170
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +133 -328
- package/dist/data-structures/binary-tree/avl-tree.d.ts +103 -69
- package/dist/data-structures/binary-tree/avl-tree.js +130 -70
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +3 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +268 -202
- package/dist/data-structures/binary-tree/binary-tree.js +311 -263
- package/dist/data-structures/binary-tree/bst.d.ts +193 -139
- package/dist/data-structures/binary-tree/bst.js +248 -164
- package/dist/data-structures/binary-tree/index.d.ts +3 -1
- package/dist/data-structures/binary-tree/index.js +3 -1
- package/dist/data-structures/binary-tree/red-black-tree.d.ts +286 -0
- package/dist/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +176 -107
- package/dist/data-structures/binary-tree/tree-counter.d.ts +212 -0
- package/dist/data-structures/binary-tree/tree-counter.js +444 -0
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +78 -170
- package/dist/data-structures/binary-tree/tree-multi-map.js +145 -367
- package/dist/data-structures/graph/abstract-graph.js +2 -2
- package/dist/data-structures/graph/directed-graph.d.ts +3 -0
- package/dist/data-structures/graph/directed-graph.js +3 -0
- package/dist/data-structures/graph/map-graph.d.ts +3 -0
- package/dist/data-structures/graph/map-graph.js +3 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +3 -0
- package/dist/data-structures/graph/undirected-graph.js +3 -0
- package/dist/data-structures/hash/hash-map.d.ts +31 -1
- package/dist/data-structures/hash/hash-map.js +35 -5
- package/dist/data-structures/heap/heap.d.ts +20 -3
- package/dist/data-structures/heap/heap.js +31 -11
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +46 -11
- package/dist/data-structures/linked-list/doubly-linked-list.js +68 -21
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +47 -11
- package/dist/data-structures/linked-list/singly-linked-list.js +73 -26
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +3 -0
- package/dist/data-structures/linked-list/skip-linked-list.js +3 -0
- package/dist/data-structures/matrix/matrix.d.ts +3 -0
- package/dist/data-structures/matrix/matrix.js +3 -0
- package/dist/data-structures/matrix/navigator.d.ts +3 -0
- package/dist/data-structures/matrix/navigator.js +3 -0
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
- package/dist/data-structures/priority-queue/max-priority-queue.js +3 -0
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
- package/dist/data-structures/priority-queue/min-priority-queue.js +3 -0
- package/dist/data-structures/queue/deque.d.ts +37 -8
- package/dist/data-structures/queue/deque.js +73 -29
- package/dist/data-structures/queue/queue.d.ts +41 -1
- package/dist/data-structures/queue/queue.js +51 -9
- package/dist/data-structures/stack/stack.d.ts +27 -10
- package/dist/data-structures/stack/stack.js +39 -20
- package/dist/data-structures/trie/trie.d.ts +8 -7
- package/dist/data-structures/trie/trie.js +8 -7
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/interfaces/binary-tree.d.ts +8 -8
- package/dist/types/data-structures/base/base.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -4
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -3
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
- package/dist/types/data-structures/binary-tree/bst.d.ts +4 -4
- package/dist/types/data-structures/binary-tree/index.d.ts +3 -1
- package/dist/types/data-structures/binary-tree/index.js +3 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
- package/dist/types/data-structures/binary-tree/tree-counter.js +2 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -5
- package/package.json +3 -3
- package/src/common/index.ts +7 -1
- package/src/data-structures/base/iterable-entry-base.ts +4 -4
- package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +151 -370
- package/src/data-structures/binary-tree/avl-tree.ts +162 -105
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
- package/src/data-structures/binary-tree/binary-tree.ts +488 -416
- package/src/data-structures/binary-tree/bst.ts +326 -251
- package/src/data-structures/binary-tree/index.ts +3 -1
- package/src/data-structures/binary-tree/{rb-tree.ts → red-black-tree.ts} +219 -145
- package/src/data-structures/binary-tree/tree-counter.ts +504 -0
- package/src/data-structures/binary-tree/tree-multi-map.ts +159 -401
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +3 -0
- package/src/data-structures/graph/map-graph.ts +3 -0
- package/src/data-structures/graph/undirected-graph.ts +3 -0
- package/src/data-structures/hash/hash-map.ts +37 -7
- package/src/data-structures/heap/heap.ts +33 -10
- package/src/data-structures/linked-list/doubly-linked-list.ts +75 -21
- package/src/data-structures/linked-list/singly-linked-list.ts +80 -27
- package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
- package/src/data-structures/matrix/matrix.ts +3 -0
- package/src/data-structures/matrix/navigator.ts +3 -0
- package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
- package/src/data-structures/queue/deque.ts +72 -28
- package/src/data-structures/queue/queue.ts +50 -7
- package/src/data-structures/stack/stack.ts +39 -20
- package/src/data-structures/trie/trie.ts +8 -7
- package/src/index.ts +4 -4
- package/src/interfaces/binary-tree.ts +10 -21
- package/src/types/data-structures/base/base.ts +1 -1
- package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -6
- package/src/types/data-structures/binary-tree/avl-tree.ts +0 -5
- package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
- package/src/types/data-structures/binary-tree/bst.ts +6 -6
- package/src/types/data-structures/binary-tree/index.ts +3 -1
- package/src/types/data-structures/binary-tree/red-black-tree.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +2 -7
- package/dist/data-structures/binary-tree/rb-tree.d.ts +0 -209
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +0 -6
- package/src/types/data-structures/binary-tree/rb-tree.ts +0 -10
- /package/dist/types/data-structures/binary-tree/{rb-tree.js → avl-tree-counter.js} +0 -0
|
@@ -6,30 +6,26 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import { BST, BSTNode } from './bst';
|
|
9
|
-
import type {
|
|
9
|
+
import type { AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, OptNodeOrNull } from '../../types';
|
|
10
10
|
import { IBinaryTree } from '../../interfaces';
|
|
11
|
-
export declare class AVLTreeNode<K = any, V = any
|
|
11
|
+
export declare class AVLTreeNode<K = any, V = any> extends BSTNode<K, V> {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param {V} [value] - The
|
|
18
|
-
*
|
|
13
|
+
* This TypeScript constructor function initializes an instance with a key and an optional value.
|
|
14
|
+
* @param {K} key - The `key` parameter is typically used to uniquely identify an object or element
|
|
15
|
+
* within a data structure. It serves as a reference or identifier for accessing or manipulating the
|
|
16
|
+
* associated value or data.
|
|
17
|
+
* @param {V} [value] - The `value` parameter in the constructor is optional, meaning it does not
|
|
18
|
+
* have to be provided when creating an instance of the class. If a value is not provided, it will
|
|
19
|
+
* default to `undefined`.
|
|
19
20
|
*/
|
|
20
21
|
constructor(key: K, value?: V);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
get
|
|
27
|
-
|
|
28
|
-
* The above function sets the value of the height property.
|
|
29
|
-
* @param {number} value - The value parameter is a number that represents the new height value to be
|
|
30
|
-
* set.
|
|
31
|
-
*/
|
|
32
|
-
set height(value: number);
|
|
22
|
+
parent?: AVLTreeNode<K, V>;
|
|
23
|
+
_left?: OptNodeOrNull<AVLTreeNode<K, V>>;
|
|
24
|
+
get left(): OptNodeOrNull<AVLTreeNode<K, V>>;
|
|
25
|
+
set left(v: OptNodeOrNull<AVLTreeNode<K, V>>);
|
|
26
|
+
_right?: OptNodeOrNull<AVLTreeNode<K, V>>;
|
|
27
|
+
get right(): OptNodeOrNull<AVLTreeNode<K, V>>;
|
|
28
|
+
set right(v: OptNodeOrNull<AVLTreeNode<K, V>>);
|
|
33
29
|
}
|
|
34
30
|
/**
|
|
35
31
|
* 1. Height-Balanced: Each node's left and right subtrees differ in height by no more than one.
|
|
@@ -40,161 +36,199 @@ export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V
|
|
|
40
36
|
* 6. Complex Insertions and Deletions: Due to rebalancing, these operations are more complex than in a regular BST.
|
|
41
37
|
* 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
|
|
42
38
|
*/
|
|
43
|
-
export declare class AVLTree<K = any, V = any, R = object,
|
|
39
|
+
export declare class AVLTree<K = any, V = any, R = object, MK = any, MV = any, MR = object> extends BST<K, V, R, MK, MV, MR> implements IBinaryTree<K, V, R, MK, MV, MR> {
|
|
44
40
|
/**
|
|
45
|
-
* This
|
|
46
|
-
*
|
|
47
|
-
* @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
|
|
48
|
-
* iterable
|
|
49
|
-
*
|
|
50
|
-
* @param [options] - The `options` parameter
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
41
|
+
* This TypeScript constructor initializes an AVLTree with keys, nodes, entries, or raw data provided
|
|
42
|
+
* in an iterable format.
|
|
43
|
+
* @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
|
|
44
|
+
* iterable that can contain either `BTNRep<K, V, AVLTreeNode<K, V>>` objects or `R` objects. It is
|
|
45
|
+
* used to initialize the AVLTree with key-value pairs or raw data entries. If provided
|
|
46
|
+
* @param [options] - The `options` parameter in the constructor is of type `AVLTreeOptions<K, V,
|
|
47
|
+
* R>`. It is an optional parameter that allows you to specify additional options for configuring the
|
|
48
|
+
* AVL tree. These options could include things like custom comparators, initial capacity, or any
|
|
49
|
+
* other configuration settings specific
|
|
54
50
|
*/
|
|
55
|
-
constructor(keysNodesEntriesOrRaws?: Iterable<
|
|
51
|
+
constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V, AVLTreeNode<K, V>> | R>, options?: AVLTreeOptions<K, V, R>);
|
|
56
52
|
/**
|
|
53
|
+
* Time Complexity: O(1)
|
|
54
|
+
* Space Complexity: O(1)
|
|
55
|
+
*
|
|
57
56
|
* The function creates a new AVL tree node with the given key and value.
|
|
58
57
|
* @param {K} key - The key parameter is of type K, which represents the key of the node being
|
|
59
58
|
* created.
|
|
60
59
|
* @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
|
|
61
60
|
* value associated with the key in the node being created.
|
|
62
61
|
* @returns The method is returning a new instance of the AVLTreeNode class, casted as the generic
|
|
63
|
-
* type
|
|
62
|
+
* type AVLTreeNode<K, V>.
|
|
64
63
|
*/
|
|
65
|
-
createNode(key: K, value?: V):
|
|
64
|
+
createNode(key: K, value?: V): AVLTreeNode<K, V>;
|
|
66
65
|
/**
|
|
66
|
+
* Time Complexity: O(1)
|
|
67
|
+
* Space Complexity: O(1)
|
|
68
|
+
*
|
|
67
69
|
* The function creates a new AVL tree with the specified options and returns it.
|
|
68
70
|
* @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
|
|
69
71
|
* passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
|
|
70
72
|
* being created.
|
|
71
73
|
* @returns a new AVLTree object.
|
|
72
74
|
*/
|
|
73
|
-
createTree(options?: AVLTreeOptions<K, V, R>):
|
|
75
|
+
createTree(options?: AVLTreeOptions<K, V, R>): AVLTree<K, V, R, MK, MV, MR>;
|
|
74
76
|
/**
|
|
77
|
+
* Time Complexity: O(1)
|
|
78
|
+
* Space Complexity: O(1)
|
|
79
|
+
*
|
|
75
80
|
* The function checks if the input is an instance of AVLTreeNode.
|
|
76
|
-
* @param {BTNRep<K, V,
|
|
77
|
-
* `
|
|
78
|
-
* @returns a boolean value indicating whether the input parameter `
|
|
81
|
+
* @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
|
|
82
|
+
* `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, AVLTreeNode<K, V>>`.
|
|
83
|
+
* @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
|
|
79
84
|
* an instance of the `AVLTreeNode` class.
|
|
80
85
|
*/
|
|
81
|
-
isNode(
|
|
86
|
+
isNode(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>): keyNodeOrEntry is AVLTreeNode<K, V>;
|
|
82
87
|
/**
|
|
83
88
|
* Time Complexity: O(log n)
|
|
84
|
-
* Space Complexity: O(
|
|
89
|
+
* Space Complexity: O(log n)
|
|
85
90
|
*
|
|
86
91
|
* The function overrides the add method of a class and inserts a key-value pair into a data
|
|
87
92
|
* structure, then balances the path.
|
|
88
|
-
* @param {BTNRep<K, V,
|
|
89
|
-
* `
|
|
90
|
-
* `RawElement`.
|
|
93
|
+
* @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
|
|
94
|
+
* `keyNodeOrEntry` can accept values of type `R`, `BTNRep<K, V, AVLTreeNode<K, V>>`
|
|
91
95
|
* @param {V} [value] - The `value` parameter is an optional value that you want to associate with
|
|
92
96
|
* the key or node being added to the data structure.
|
|
93
97
|
* @returns The method is returning a boolean value.
|
|
94
98
|
*/
|
|
95
|
-
add(
|
|
99
|
+
add(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>, value?: V): boolean;
|
|
96
100
|
/**
|
|
97
101
|
* Time Complexity: O(log n)
|
|
98
|
-
* Space Complexity: O(
|
|
102
|
+
* Space Complexity: O(log n)
|
|
99
103
|
*
|
|
100
104
|
* The function overrides the delete method in a TypeScript class, performs deletion, and then
|
|
101
105
|
* balances the tree if necessary.
|
|
102
|
-
* @param {BTNRep<K, V,
|
|
106
|
+
* @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
|
|
103
107
|
* parameter in the `override delete` method can be one of the following types:
|
|
104
108
|
* @returns The `delete` method is being overridden in this code snippet. It first calls the `delete`
|
|
105
109
|
* method from the superclass (presumably a parent class) with the provided `predicate`, which could
|
|
106
110
|
* be a key, node, entry, or a custom predicate. The result of this deletion operation is stored in
|
|
107
111
|
* `deletedResults`, which is an array of `BinaryTreeDeleteResult` objects.
|
|
108
112
|
*/
|
|
109
|
-
delete(
|
|
113
|
+
delete(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>): BinaryTreeDeleteResult<AVLTreeNode<K, V>>[];
|
|
114
|
+
/**
|
|
115
|
+
* Time Complexity: O(n)
|
|
116
|
+
* Space Complexity: O(n)
|
|
117
|
+
*
|
|
118
|
+
* The `map` function in TypeScript overrides the default map behavior of an AVLTree data structure
|
|
119
|
+
* by applying a callback function to each entry and creating a new AVLTree with the results.
|
|
120
|
+
* @param callback - A function that will be called for each entry in the AVLTree. It takes four
|
|
121
|
+
* arguments: the key, the value (which can be undefined), the index of the entry, and a reference to
|
|
122
|
+
* the AVLTree itself.
|
|
123
|
+
* @param [options] - The `options` parameter in the `override map` function is of type
|
|
124
|
+
* `AVLTreeOptions<MK, MV, MR>`. It is an optional parameter that allows you to specify additional
|
|
125
|
+
* options for the AVL tree being created during the mapping process. These options could include
|
|
126
|
+
* custom comparators, initial
|
|
127
|
+
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
|
|
128
|
+
* the value of `this` when executing the `callback` function. It allows you to set the context
|
|
129
|
+
* (value of `this`) within the callback function. This can be useful when you want to access
|
|
130
|
+
* properties or
|
|
131
|
+
* @returns The `map` method is returning a new AVLTree instance (`newTree`) with the entries
|
|
132
|
+
* modified by the provided callback function.
|
|
133
|
+
*/
|
|
134
|
+
map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: AVLTreeOptions<MK, MV, MR>, thisArg?: any): AVLTree<MK, MV, MR>;
|
|
135
|
+
/**
|
|
136
|
+
* Time Complexity: O(n)
|
|
137
|
+
* Space Complexity: O(n)
|
|
138
|
+
*
|
|
139
|
+
* The function `clone` overrides the default cloning behavior to create a deep copy of a tree
|
|
140
|
+
* structure.
|
|
141
|
+
* @returns A cloned tree object is being returned.
|
|
142
|
+
*/
|
|
143
|
+
clone(): AVLTree<K, V, R, MK, MV, MR>;
|
|
110
144
|
/**
|
|
111
145
|
* Time Complexity: O(1)
|
|
112
146
|
* Space Complexity: O(1)
|
|
113
147
|
*
|
|
114
148
|
* The `_swapProperties` function swaps the key, value, and height properties between two nodes in a
|
|
115
149
|
* binary search tree.
|
|
116
|
-
* @param {
|
|
117
|
-
* object (`
|
|
118
|
-
* @param {
|
|
119
|
-
* `R` or an instance of `BSTNOptKeyOrNode<K,
|
|
150
|
+
* @param {BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>} srcNode - The `srcNode` parameter represents either a node
|
|
151
|
+
* object (`AVLTreeNode<K, V>`) or a key-value pair (`R`) that is being swapped with another node.
|
|
152
|
+
* @param {BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>} destNode - The `destNode` parameter is either an instance of
|
|
153
|
+
* `R` or an instance of `BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>`.
|
|
120
154
|
* @returns The method is returning the `destNodeEnsured` object if both `srcNodeEnsured` and
|
|
121
155
|
* `destNodeEnsured` are truthy. Otherwise, it returns `undefined`.
|
|
122
156
|
*/
|
|
123
|
-
protected _swapProperties(srcNode:
|
|
157
|
+
protected _swapProperties(srcNode: BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>, destNode: BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>): AVLTreeNode<K, V> | undefined;
|
|
124
158
|
/**
|
|
125
159
|
* Time Complexity: O(1)
|
|
126
160
|
* Space Complexity: O(1)
|
|
127
161
|
*
|
|
128
162
|
* The function calculates the balance factor of a node in a binary tree.
|
|
129
|
-
* @param {
|
|
163
|
+
* @param {AVLTreeNode<K, V>} node - The parameter "node" is of type "AVLTreeNode<K, V>", which likely represents a node in a
|
|
130
164
|
* binary tree data structure.
|
|
131
165
|
* @returns the balance factor of a given node. The balance factor is calculated by subtracting the
|
|
132
166
|
* height of the left subtree from the height of the right subtree.
|
|
133
167
|
*/
|
|
134
|
-
protected _balanceFactor(node:
|
|
168
|
+
protected _balanceFactor(node: AVLTreeNode<K, V>): number;
|
|
135
169
|
/**
|
|
136
170
|
* Time Complexity: O(1)
|
|
137
171
|
* Space Complexity: O(1)
|
|
138
172
|
*
|
|
139
173
|
* The function updates the height of a node in a binary tree based on the heights of its left and
|
|
140
174
|
* right children.
|
|
141
|
-
* @param {
|
|
175
|
+
* @param {AVLTreeNode<K, V>} node - The parameter "node" represents a node in a binary tree data structure.
|
|
142
176
|
*/
|
|
143
|
-
protected _updateHeight(node:
|
|
177
|
+
protected _updateHeight(node: AVLTreeNode<K, V>): void;
|
|
144
178
|
/**
|
|
145
179
|
* Time Complexity: O(1)
|
|
146
180
|
* Space Complexity: O(1)
|
|
147
181
|
*
|
|
148
182
|
* The `_balanceLL` function performs a left-left rotation to balance a binary search tree.
|
|
149
|
-
* @param {
|
|
183
|
+
* @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
|
|
150
184
|
*/
|
|
151
|
-
protected _balanceLL(A:
|
|
185
|
+
protected _balanceLL(A: AVLTreeNode<K, V>): void;
|
|
152
186
|
/**
|
|
153
187
|
* Time Complexity: O(1)
|
|
154
188
|
* Space Complexity: O(1)
|
|
155
189
|
*
|
|
156
190
|
* The `_balanceLR` function performs a left-right rotation to balance a binary tree.
|
|
157
|
-
* @param {
|
|
191
|
+
* @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
|
|
158
192
|
*/
|
|
159
|
-
protected _balanceLR(A:
|
|
193
|
+
protected _balanceLR(A: AVLTreeNode<K, V>): void;
|
|
160
194
|
/**
|
|
161
195
|
* Time Complexity: O(1)
|
|
162
196
|
* Space Complexity: O(1)
|
|
163
197
|
*
|
|
164
198
|
* The function `_balanceRR` performs a right-right rotation to balance a binary tree.
|
|
165
|
-
* @param {
|
|
199
|
+
* @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
|
|
166
200
|
*/
|
|
167
|
-
protected _balanceRR(A:
|
|
201
|
+
protected _balanceRR(A: AVLTreeNode<K, V>): void;
|
|
168
202
|
/**
|
|
169
203
|
* Time Complexity: O(1)
|
|
170
204
|
* Space Complexity: O(1)
|
|
171
205
|
*
|
|
172
206
|
* The function `_balanceRL` performs a right-left rotation to balance a binary tree.
|
|
173
|
-
* @param {
|
|
207
|
+
* @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
|
|
174
208
|
*/
|
|
175
|
-
protected _balanceRL(A:
|
|
209
|
+
protected _balanceRL(A: AVLTreeNode<K, V>): void;
|
|
176
210
|
/**
|
|
177
211
|
* Time Complexity: O(log n)
|
|
178
212
|
* Space Complexity: O(1)
|
|
179
213
|
*
|
|
180
214
|
* The `_balancePath` function is used to update the heights of nodes and perform rotation operations
|
|
181
215
|
* to restore balance in an AVL tree after inserting a node.
|
|
182
|
-
* @param {BTNRep<K, V,
|
|
183
|
-
* `BTNRep<K, V,
|
|
216
|
+
* @param {BTNRep<K, V, AVLTreeNode<K, V>>} node - The `node` parameter can be of type `R` or
|
|
217
|
+
* `BTNRep<K, V, AVLTreeNode<K, V>>`.
|
|
184
218
|
*/
|
|
185
|
-
protected _balancePath(node: BTNRep<K, V,
|
|
219
|
+
protected _balancePath(node: BTNRep<K, V, AVLTreeNode<K, V>>): void;
|
|
186
220
|
/**
|
|
187
221
|
* Time Complexity: O(1)
|
|
188
222
|
* Space Complexity: O(1)
|
|
189
223
|
*
|
|
190
224
|
* The function replaces an old node with a new node and sets the height of the new node to be the
|
|
191
225
|
* same as the old node.
|
|
192
|
-
* @param {
|
|
226
|
+
* @param {AVLTreeNode<K, V>} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
|
|
193
227
|
* the data structure.
|
|
194
|
-
* @param {
|
|
228
|
+
* @param {AVLTreeNode<K, V>} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
|
|
195
229
|
* the data structure.
|
|
196
230
|
* @returns The method is returning the result of calling the `_replaceNode` method from the
|
|
197
231
|
* superclass, with the `oldNode` and `newNode` as arguments.
|
|
198
232
|
*/
|
|
199
|
-
protected _replaceNode(oldNode:
|
|
233
|
+
protected _replaceNode(oldNode: AVLTreeNode<K, V>, newNode: AVLTreeNode<K, V>): AVLTreeNode<K, V>;
|
|
200
234
|
}
|