bst-typed 1.53.9 → 1.54.1
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/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 -189
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +133 -357
- package/dist/data-structures/binary-tree/avl-tree.d.ts +108 -78
- package/dist/data-structures/binary-tree/avl-tree.js +126 -79
- 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 +243 -190
- package/dist/data-structures/binary-tree/binary-tree.js +273 -229
- package/dist/data-structures/binary-tree/bst.d.ts +141 -122
- package/dist/data-structures/binary-tree/bst.js +170 -134
- package/dist/data-structures/binary-tree/index.d.ts +2 -0
- package/dist/data-structures/binary-tree/index.js +2 -0
- package/dist/data-structures/binary-tree/red-black-tree.d.ts +84 -80
- package/dist/data-structures/binary-tree/red-black-tree.js +101 -79
- 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 -186
- package/dist/data-structures/binary-tree/tree-multi-map.js +140 -388
- 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/linked-list/singly-linked-list.d.ts +3 -0
- package/dist/data-structures/linked-list/singly-linked-list.js +3 -0
- 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/trie/trie.d.ts +0 -4
- package/dist/data-structures/trie/trie.js +0 -4
- package/dist/interfaces/binary-tree.d.ts +7 -6
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/types/data-structures/binary-tree/avl-tree-counter.js +2 -0
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +3 -2
- package/dist/types/data-structures/binary-tree/index.d.ts +2 -0
- package/dist/types/data-structures/binary-tree/index.js +2 -0
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +1 -3
- 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 +1 -3
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +148 -394
- package/src/data-structures/binary-tree/avl-tree.ts +152 -112
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
- package/src/data-structures/binary-tree/binary-tree.ts +446 -379
- package/src/data-structures/binary-tree/bst.ts +224 -201
- package/src/data-structures/binary-tree/index.ts +2 -0
- package/src/data-structures/binary-tree/red-black-tree.ts +138 -114
- package/src/data-structures/binary-tree/tree-counter.ts +504 -0
- package/src/data-structures/binary-tree/tree-multi-map.ts +156 -428
- 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/linked-list/singly-linked-list.ts +3 -0
- 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/trie/trie.ts +0 -4
- package/src/interfaces/binary-tree.ts +10 -11
- 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 -4
- package/src/types/data-structures/binary-tree/avl-tree.ts +0 -3
- package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
- package/src/types/data-structures/binary-tree/bst.ts +5 -3
- package/src/types/data-structures/binary-tree/index.ts +2 -0
- package/src/types/data-structures/binary-tree/rb-tree.ts +1 -4
- package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -4
|
@@ -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,165 +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
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
66
|
+
* Time Complexity: O(1)
|
|
67
|
+
* Space Complexity: O(1)
|
|
68
|
+
*
|
|
69
|
+
* The function creates a new AVL tree with the specified options and returns it.
|
|
70
|
+
* @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
|
|
71
|
+
* passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
|
|
72
|
+
* being created.
|
|
73
|
+
* @returns a new AVLTree object.
|
|
75
74
|
*/
|
|
76
|
-
createTree(options?: AVLTreeOptions<K, V, R>): AVLTree<K, V, R,
|
|
75
|
+
createTree(options?: AVLTreeOptions<K, V, R>): AVLTree<K, V, R, MK, MV, MR>;
|
|
77
76
|
/**
|
|
77
|
+
* Time Complexity: O(1)
|
|
78
|
+
* Space Complexity: O(1)
|
|
79
|
+
*
|
|
78
80
|
* The function checks if the input is an instance of AVLTreeNode.
|
|
79
|
-
* @param {BTNRep<K, V,
|
|
80
|
-
* `
|
|
81
|
-
* @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
|
|
82
84
|
* an instance of the `AVLTreeNode` class.
|
|
83
85
|
*/
|
|
84
|
-
isNode(
|
|
86
|
+
isNode(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>): keyNodeOrEntry is AVLTreeNode<K, V>;
|
|
85
87
|
/**
|
|
86
88
|
* Time Complexity: O(log n)
|
|
87
|
-
* Space Complexity: O(
|
|
89
|
+
* Space Complexity: O(log n)
|
|
88
90
|
*
|
|
89
91
|
* The function overrides the add method of a class and inserts a key-value pair into a data
|
|
90
92
|
* structure, then balances the path.
|
|
91
|
-
* @param {BTNRep<K, V,
|
|
92
|
-
* `
|
|
93
|
-
* `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>>`
|
|
94
95
|
* @param {V} [value] - The `value` parameter is an optional value that you want to associate with
|
|
95
96
|
* the key or node being added to the data structure.
|
|
96
97
|
* @returns The method is returning a boolean value.
|
|
97
98
|
*/
|
|
98
|
-
add(
|
|
99
|
+
add(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>, value?: V): boolean;
|
|
99
100
|
/**
|
|
100
101
|
* Time Complexity: O(log n)
|
|
101
|
-
* Space Complexity: O(
|
|
102
|
+
* Space Complexity: O(log n)
|
|
102
103
|
*
|
|
103
104
|
* The function overrides the delete method in a TypeScript class, performs deletion, and then
|
|
104
105
|
* balances the tree if necessary.
|
|
105
|
-
* @param {BTNRep<K, V,
|
|
106
|
+
* @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
|
|
106
107
|
* parameter in the `override delete` method can be one of the following types:
|
|
107
108
|
* @returns The `delete` method is being overridden in this code snippet. It first calls the `delete`
|
|
108
109
|
* method from the superclass (presumably a parent class) with the provided `predicate`, which could
|
|
109
110
|
* be a key, node, entry, or a custom predicate. The result of this deletion operation is stored in
|
|
110
111
|
* `deletedResults`, which is an array of `BinaryTreeDeleteResult` objects.
|
|
111
112
|
*/
|
|
112
|
-
delete(
|
|
113
|
-
|
|
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>;
|
|
114
144
|
/**
|
|
115
145
|
* Time Complexity: O(1)
|
|
116
146
|
* Space Complexity: O(1)
|
|
117
147
|
*
|
|
118
148
|
* The `_swapProperties` function swaps the key, value, and height properties between two nodes in a
|
|
119
149
|
* binary search tree.
|
|
120
|
-
* @param {
|
|
121
|
-
* object (`
|
|
122
|
-
* @param {
|
|
123
|
-
* `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>>`.
|
|
124
154
|
* @returns The method is returning the `destNodeEnsured` object if both `srcNodeEnsured` and
|
|
125
155
|
* `destNodeEnsured` are truthy. Otherwise, it returns `undefined`.
|
|
126
156
|
*/
|
|
127
|
-
protected _swapProperties(srcNode:
|
|
157
|
+
protected _swapProperties(srcNode: BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>, destNode: BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>): AVLTreeNode<K, V> | undefined;
|
|
128
158
|
/**
|
|
129
159
|
* Time Complexity: O(1)
|
|
130
160
|
* Space Complexity: O(1)
|
|
131
161
|
*
|
|
132
162
|
* The function calculates the balance factor of a node in a binary tree.
|
|
133
|
-
* @param {
|
|
163
|
+
* @param {AVLTreeNode<K, V>} node - The parameter "node" is of type "AVLTreeNode<K, V>", which likely represents a node in a
|
|
134
164
|
* binary tree data structure.
|
|
135
165
|
* @returns the balance factor of a given node. The balance factor is calculated by subtracting the
|
|
136
166
|
* height of the left subtree from the height of the right subtree.
|
|
137
167
|
*/
|
|
138
|
-
protected _balanceFactor(node:
|
|
168
|
+
protected _balanceFactor(node: AVLTreeNode<K, V>): number;
|
|
139
169
|
/**
|
|
140
170
|
* Time Complexity: O(1)
|
|
141
171
|
* Space Complexity: O(1)
|
|
142
172
|
*
|
|
143
173
|
* The function updates the height of a node in a binary tree based on the heights of its left and
|
|
144
174
|
* right children.
|
|
145
|
-
* @param {
|
|
175
|
+
* @param {AVLTreeNode<K, V>} node - The parameter "node" represents a node in a binary tree data structure.
|
|
146
176
|
*/
|
|
147
|
-
protected _updateHeight(node:
|
|
177
|
+
protected _updateHeight(node: AVLTreeNode<K, V>): void;
|
|
148
178
|
/**
|
|
149
179
|
* Time Complexity: O(1)
|
|
150
180
|
* Space Complexity: O(1)
|
|
151
181
|
*
|
|
152
182
|
* The `_balanceLL` function performs a left-left rotation to balance a binary search tree.
|
|
153
|
-
* @param {
|
|
183
|
+
* @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
|
|
154
184
|
*/
|
|
155
|
-
protected _balanceLL(A:
|
|
185
|
+
protected _balanceLL(A: AVLTreeNode<K, V>): void;
|
|
156
186
|
/**
|
|
157
187
|
* Time Complexity: O(1)
|
|
158
188
|
* Space Complexity: O(1)
|
|
159
189
|
*
|
|
160
190
|
* The `_balanceLR` function performs a left-right rotation to balance a binary tree.
|
|
161
|
-
* @param {
|
|
191
|
+
* @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
|
|
162
192
|
*/
|
|
163
|
-
protected _balanceLR(A:
|
|
193
|
+
protected _balanceLR(A: AVLTreeNode<K, V>): void;
|
|
164
194
|
/**
|
|
165
195
|
* Time Complexity: O(1)
|
|
166
196
|
* Space Complexity: O(1)
|
|
167
197
|
*
|
|
168
198
|
* The function `_balanceRR` performs a right-right rotation to balance a binary tree.
|
|
169
|
-
* @param {
|
|
199
|
+
* @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
|
|
170
200
|
*/
|
|
171
|
-
protected _balanceRR(A:
|
|
201
|
+
protected _balanceRR(A: AVLTreeNode<K, V>): void;
|
|
172
202
|
/**
|
|
173
203
|
* Time Complexity: O(1)
|
|
174
204
|
* Space Complexity: O(1)
|
|
175
205
|
*
|
|
176
206
|
* The function `_balanceRL` performs a right-left rotation to balance a binary tree.
|
|
177
|
-
* @param {
|
|
207
|
+
* @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
|
|
178
208
|
*/
|
|
179
|
-
protected _balanceRL(A:
|
|
209
|
+
protected _balanceRL(A: AVLTreeNode<K, V>): void;
|
|
180
210
|
/**
|
|
181
211
|
* Time Complexity: O(log n)
|
|
182
212
|
* Space Complexity: O(1)
|
|
183
213
|
*
|
|
184
214
|
* The `_balancePath` function is used to update the heights of nodes and perform rotation operations
|
|
185
215
|
* to restore balance in an AVL tree after inserting a node.
|
|
186
|
-
* @param {BTNRep<K, V,
|
|
187
|
-
* `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>>`.
|
|
188
218
|
*/
|
|
189
|
-
protected _balancePath(node: BTNRep<K, V,
|
|
219
|
+
protected _balancePath(node: BTNRep<K, V, AVLTreeNode<K, V>>): void;
|
|
190
220
|
/**
|
|
191
221
|
* Time Complexity: O(1)
|
|
192
222
|
* Space Complexity: O(1)
|
|
193
223
|
*
|
|
194
224
|
* The function replaces an old node with a new node and sets the height of the new node to be the
|
|
195
225
|
* same as the old node.
|
|
196
|
-
* @param {
|
|
226
|
+
* @param {AVLTreeNode<K, V>} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
|
|
197
227
|
* the data structure.
|
|
198
|
-
* @param {
|
|
228
|
+
* @param {AVLTreeNode<K, V>} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
|
|
199
229
|
* the data structure.
|
|
200
230
|
* @returns The method is returning the result of calling the `_replaceNode` method from the
|
|
201
231
|
* superclass, with the `oldNode` and `newNode` as arguments.
|
|
202
232
|
*/
|
|
203
|
-
protected _replaceNode(oldNode:
|
|
233
|
+
protected _replaceNode(oldNode: AVLTreeNode<K, V>, newNode: AVLTreeNode<K, V>): AVLTreeNode<K, V>;
|
|
204
234
|
}
|