heap-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.
Files changed (84) hide show
  1. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
  2. package/dist/data-structures/binary-tree/avl-tree-counter.js +407 -0
  3. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -189
  4. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +133 -357
  5. package/dist/data-structures/binary-tree/avl-tree.d.ts +108 -78
  6. package/dist/data-structures/binary-tree/avl-tree.js +126 -79
  7. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  8. package/dist/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  9. package/dist/data-structures/binary-tree/binary-tree.d.ts +243 -190
  10. package/dist/data-structures/binary-tree/binary-tree.js +273 -229
  11. package/dist/data-structures/binary-tree/bst.d.ts +141 -122
  12. package/dist/data-structures/binary-tree/bst.js +170 -134
  13. package/dist/data-structures/binary-tree/index.d.ts +2 -0
  14. package/dist/data-structures/binary-tree/index.js +2 -0
  15. package/dist/data-structures/binary-tree/red-black-tree.d.ts +84 -80
  16. package/dist/data-structures/binary-tree/red-black-tree.js +101 -79
  17. package/dist/data-structures/binary-tree/tree-counter.d.ts +212 -0
  18. package/dist/data-structures/binary-tree/tree-counter.js +444 -0
  19. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +78 -186
  20. package/dist/data-structures/binary-tree/tree-multi-map.js +140 -388
  21. package/dist/data-structures/graph/directed-graph.d.ts +3 -0
  22. package/dist/data-structures/graph/directed-graph.js +3 -0
  23. package/dist/data-structures/graph/map-graph.d.ts +3 -0
  24. package/dist/data-structures/graph/map-graph.js +3 -0
  25. package/dist/data-structures/graph/undirected-graph.d.ts +3 -0
  26. package/dist/data-structures/graph/undirected-graph.js +3 -0
  27. package/dist/data-structures/linked-list/singly-linked-list.d.ts +3 -0
  28. package/dist/data-structures/linked-list/singly-linked-list.js +3 -0
  29. package/dist/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  30. package/dist/data-structures/linked-list/skip-linked-list.js +3 -0
  31. package/dist/data-structures/matrix/matrix.d.ts +3 -0
  32. package/dist/data-structures/matrix/matrix.js +3 -0
  33. package/dist/data-structures/matrix/navigator.d.ts +3 -0
  34. package/dist/data-structures/matrix/navigator.js +3 -0
  35. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  36. package/dist/data-structures/priority-queue/max-priority-queue.js +3 -0
  37. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  38. package/dist/data-structures/priority-queue/min-priority-queue.js +3 -0
  39. package/dist/data-structures/trie/trie.d.ts +0 -4
  40. package/dist/data-structures/trie/trie.js +0 -4
  41. package/dist/interfaces/binary-tree.d.ts +7 -6
  42. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  43. package/dist/types/data-structures/binary-tree/avl-tree-counter.js +2 -0
  44. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -3
  45. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
  46. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -2
  47. package/dist/types/data-structures/binary-tree/bst.d.ts +3 -2
  48. package/dist/types/data-structures/binary-tree/index.d.ts +2 -0
  49. package/dist/types/data-structures/binary-tree/index.js +2 -0
  50. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +1 -3
  51. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  52. package/dist/types/data-structures/binary-tree/tree-counter.js +2 -0
  53. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -3
  54. package/package.json +2 -2
  55. package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
  56. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +148 -394
  57. package/src/data-structures/binary-tree/avl-tree.ts +152 -112
  58. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
  59. package/src/data-structures/binary-tree/binary-tree.ts +446 -379
  60. package/src/data-structures/binary-tree/bst.ts +224 -201
  61. package/src/data-structures/binary-tree/index.ts +2 -0
  62. package/src/data-structures/binary-tree/red-black-tree.ts +138 -114
  63. package/src/data-structures/binary-tree/tree-counter.ts +504 -0
  64. package/src/data-structures/binary-tree/tree-multi-map.ts +156 -428
  65. package/src/data-structures/graph/directed-graph.ts +3 -0
  66. package/src/data-structures/graph/map-graph.ts +3 -0
  67. package/src/data-structures/graph/undirected-graph.ts +3 -0
  68. package/src/data-structures/linked-list/singly-linked-list.ts +3 -0
  69. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  70. package/src/data-structures/matrix/matrix.ts +3 -0
  71. package/src/data-structures/matrix/navigator.ts +3 -0
  72. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
  73. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
  74. package/src/data-structures/trie/trie.ts +0 -4
  75. package/src/interfaces/binary-tree.ts +10 -11
  76. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  77. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -4
  78. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -3
  79. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
  80. package/src/types/data-structures/binary-tree/bst.ts +5 -3
  81. package/src/types/data-structures/binary-tree/index.ts +2 -0
  82. package/src/types/data-structures/binary-tree/rb-tree.ts +1 -4
  83. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  84. package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -4
@@ -11,31 +11,37 @@ exports.AVLTree = exports.AVLTreeNode = void 0;
11
11
  const bst_1 = require("./bst");
12
12
  class AVLTreeNode extends bst_1.BSTNode {
13
13
  /**
14
- * The constructor function initializes a new instance of a class with a key and an optional value,
15
- * and sets the height property to 0.
16
- * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
17
- * constructor. It is used to initialize the key property of the object being created.
18
- * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
19
- * value associated with the key in the constructor.
14
+ * This TypeScript constructor function initializes an instance with a key and an optional value.
15
+ * @param {K} key - The `key` parameter is typically used to uniquely identify an object or element
16
+ * within a data structure. It serves as a reference or identifier for accessing or manipulating the
17
+ * associated value or data.
18
+ * @param {V} [value] - The `value` parameter in the constructor is optional, meaning it does not
19
+ * have to be provided when creating an instance of the class. If a value is not provided, it will
20
+ * default to `undefined`.
20
21
  */
21
22
  constructor(key, value) {
22
23
  super(key, value);
23
- this._height = 0;
24
+ this.parent = undefined;
25
+ this._left = undefined;
26
+ this._right = undefined;
24
27
  }
25
- /**
26
- * The function returns the value of the height property.
27
- * @returns The height of the object.
28
- */
29
- get height() {
30
- return this._height;
28
+ get left() {
29
+ return this._left;
31
30
  }
32
- /**
33
- * The above function sets the value of the height property.
34
- * @param {number} value - The value parameter is a number that represents the new height value to be
35
- * set.
36
- */
37
- set height(value) {
38
- this._height = value;
31
+ set left(v) {
32
+ if (v) {
33
+ v.parent = this;
34
+ }
35
+ this._left = v;
36
+ }
37
+ get right() {
38
+ return this._right;
39
+ }
40
+ set right(v) {
41
+ if (v) {
42
+ v.parent = this;
43
+ }
44
+ this._right = v;
39
45
  }
40
46
  }
41
47
  exports.AVLTreeNode = AVLTreeNode;
@@ -50,15 +56,15 @@ exports.AVLTreeNode = AVLTreeNode;
50
56
  */
51
57
  class AVLTree extends bst_1.BST {
52
58
  /**
53
- * This is a constructor function for an AVLTree class that initializes the tree with keys, nodes,
54
- * entries, or raw elements.
55
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
56
- * iterable object that can contain either keys, nodes, entries, or raw elements. These elements will
57
- * be used to initialize the AVLTree.
58
- * @param [options] - The `options` parameter is an optional object that can be used to customize the
59
- * behavior of the AVLTree. It can include properties such as `compareFn` (a function used to compare
60
- * keys), `allowDuplicates` (a boolean indicating whether duplicate keys are allowed), and
61
- * `nodeBuilder` (
59
+ * This TypeScript constructor initializes an AVLTree with keys, nodes, entries, or raw data provided
60
+ * in an iterable format.
61
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
62
+ * iterable that can contain either `BTNRep<K, V, AVLTreeNode<K, V>>` objects or `R` objects. It is
63
+ * used to initialize the AVLTree with key-value pairs or raw data entries. If provided
64
+ * @param [options] - The `options` parameter in the constructor is of type `AVLTreeOptions<K, V,
65
+ * R>`. It is an optional parameter that allows you to specify additional options for configuring the
66
+ * AVL tree. These options could include things like custom comparators, initial capacity, or any
67
+ * other configuration settings specific
62
68
  */
63
69
  constructor(keysNodesEntriesOrRaws = [], options) {
64
70
  super([], options);
@@ -66,77 +72,81 @@ class AVLTree extends bst_1.BST {
66
72
  super.addMany(keysNodesEntriesOrRaws);
67
73
  }
68
74
  /**
75
+ * Time Complexity: O(1)
76
+ * Space Complexity: O(1)
77
+ *
69
78
  * The function creates a new AVL tree node with the given key and value.
70
79
  * @param {K} key - The key parameter is of type K, which represents the key of the node being
71
80
  * created.
72
81
  * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
73
82
  * value associated with the key in the node being created.
74
83
  * @returns The method is returning a new instance of the AVLTreeNode class, casted as the generic
75
- * type NODE.
84
+ * type AVLTreeNode<K, V>.
76
85
  */
77
86
  createNode(key, value) {
78
87
  return new AVLTreeNode(key, this._isMapMode ? undefined : value);
79
88
  }
80
89
  /**
81
- * The function `createTree` in TypeScript overrides the default AVLTree creation with the provided
82
- * options.
83
- * @param [options] - The `options` parameter in the `createTree` function is an object that contains
84
- * configuration options for creating an AVL tree. These options can include properties such as
85
- * `iterationType`, `isMapMode`, `specifyComparable`, `toEntryFn`, and `isReverse`. The function
86
- * creates a
87
- * @returns An AVLTree object is being returned with the specified options and properties inherited
88
- * from the current object.
90
+ * Time Complexity: O(1)
91
+ * Space Complexity: O(1)
92
+ *
93
+ * The function creates a new AVL tree with the specified options and returns it.
94
+ * @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
95
+ * passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
96
+ * being created.
97
+ * @returns a new AVLTree object.
89
98
  */
90
- // @ts-ignore
91
99
  createTree(options) {
92
100
  return new AVLTree([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn, isReverse: this._isReverse }, options));
93
101
  }
94
102
  /**
103
+ * Time Complexity: O(1)
104
+ * Space Complexity: O(1)
105
+ *
95
106
  * The function checks if the input is an instance of AVLTreeNode.
96
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
97
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
98
- * @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
107
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
108
+ * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, AVLTreeNode<K, V>>`.
109
+ * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
99
110
  * an instance of the `AVLTreeNode` class.
100
111
  */
101
- isNode(keyNodeEntryOrRaw) {
102
- return keyNodeEntryOrRaw instanceof AVLTreeNode;
112
+ isNode(keyNodeOrEntry) {
113
+ return keyNodeOrEntry instanceof AVLTreeNode;
103
114
  }
104
115
  /**
105
116
  * Time Complexity: O(log n)
106
- * Space Complexity: O(1)
117
+ * Space Complexity: O(log n)
107
118
  *
108
119
  * The function overrides the add method of a class and inserts a key-value pair into a data
109
120
  * structure, then balances the path.
110
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
111
- * `keyNodeEntryOrRaw` can accept values of type `R`, `BTNRep<K, V, NODE>`, or
112
- * `RawElement`.
121
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
122
+ * `keyNodeOrEntry` can accept values of type `R`, `BTNRep<K, V, AVLTreeNode<K, V>>`
113
123
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
114
124
  * the key or node being added to the data structure.
115
125
  * @returns The method is returning a boolean value.
116
126
  */
117
- add(keyNodeEntryOrRaw, value) {
118
- if (keyNodeEntryOrRaw === null)
127
+ add(keyNodeOrEntry, value) {
128
+ if (keyNodeOrEntry === null)
119
129
  return false;
120
- const inserted = super.add(keyNodeEntryOrRaw, value);
130
+ const inserted = super.add(keyNodeOrEntry, value);
121
131
  if (inserted)
122
- this._balancePath(keyNodeEntryOrRaw);
132
+ this._balancePath(keyNodeOrEntry);
123
133
  return inserted;
124
134
  }
125
135
  /**
126
136
  * Time Complexity: O(log n)
127
- * Space Complexity: O(1)
137
+ * Space Complexity: O(log n)
128
138
  *
129
139
  * The function overrides the delete method in a TypeScript class, performs deletion, and then
130
140
  * balances the tree if necessary.
131
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `keyNodeEntryOrRaw`
141
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
132
142
  * parameter in the `override delete` method can be one of the following types:
133
143
  * @returns The `delete` method is being overridden in this code snippet. It first calls the `delete`
134
144
  * method from the superclass (presumably a parent class) with the provided `predicate`, which could
135
145
  * be a key, node, entry, or a custom predicate. The result of this deletion operation is stored in
136
146
  * `deletedResults`, which is an array of `BinaryTreeDeleteResult` objects.
137
147
  */
138
- delete(keyNodeEntryOrRaw) {
139
- const deletedResults = super.delete(keyNodeEntryOrRaw);
148
+ delete(keyNodeOrEntry) {
149
+ const deletedResults = super.delete(keyNodeOrEntry);
140
150
  for (const { needBalanced } of deletedResults) {
141
151
  if (needBalanced) {
142
152
  this._balancePath(needBalanced);
@@ -144,7 +154,26 @@ class AVLTree extends bst_1.BST {
144
154
  }
145
155
  return deletedResults;
146
156
  }
147
- // @ts-ignore
157
+ /**
158
+ * Time Complexity: O(n)
159
+ * Space Complexity: O(n)
160
+ *
161
+ * The `map` function in TypeScript overrides the default map behavior of an AVLTree data structure
162
+ * by applying a callback function to each entry and creating a new AVLTree with the results.
163
+ * @param callback - A function that will be called for each entry in the AVLTree. It takes four
164
+ * arguments: the key, the value (which can be undefined), the index of the entry, and a reference to
165
+ * the AVLTree itself.
166
+ * @param [options] - The `options` parameter in the `override map` function is of type
167
+ * `AVLTreeOptions<MK, MV, MR>`. It is an optional parameter that allows you to specify additional
168
+ * options for the AVL tree being created during the mapping process. These options could include
169
+ * custom comparators, initial
170
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
171
+ * the value of `this` when executing the `callback` function. It allows you to set the context
172
+ * (value of `this`) within the callback function. This can be useful when you want to access
173
+ * properties or
174
+ * @returns The `map` method is returning a new AVLTree instance (`newTree`) with the entries
175
+ * modified by the provided callback function.
176
+ */
148
177
  map(callback, options, thisArg) {
149
178
  const newTree = new AVLTree([], options);
150
179
  let index = 0;
@@ -153,16 +182,29 @@ class AVLTree extends bst_1.BST {
153
182
  }
154
183
  return newTree;
155
184
  }
185
+ /**
186
+ * Time Complexity: O(n)
187
+ * Space Complexity: O(n)
188
+ *
189
+ * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
190
+ * structure.
191
+ * @returns A cloned tree object is being returned.
192
+ */
193
+ clone() {
194
+ const cloned = this.createTree();
195
+ this._clone(cloned);
196
+ return cloned;
197
+ }
156
198
  /**
157
199
  * Time Complexity: O(1)
158
200
  * Space Complexity: O(1)
159
201
  *
160
202
  * The `_swapProperties` function swaps the key, value, and height properties between two nodes in a
161
203
  * binary search tree.
162
- * @param {R | BSTNOptKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents either a node
163
- * object (`NODE`) or a key-value pair (`R`) that is being swapped with another node.
164
- * @param {R | BSTNOptKeyOrNode<K, NODE>} destNode - The `destNode` parameter is either an instance of
165
- * `R` or an instance of `BSTNOptKeyOrNode<K, NODE>`.
204
+ * @param {BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>} srcNode - The `srcNode` parameter represents either a node
205
+ * object (`AVLTreeNode<K, V>`) or a key-value pair (`R`) that is being swapped with another node.
206
+ * @param {BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>} destNode - The `destNode` parameter is either an instance of
207
+ * `R` or an instance of `BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>`.
166
208
  * @returns The method is returning the `destNodeEnsured` object if both `srcNodeEnsured` and
167
209
  * `destNodeEnsured` are truthy. Otherwise, it returns `undefined`.
168
210
  */
@@ -192,7 +234,7 @@ class AVLTree extends bst_1.BST {
192
234
  * Space Complexity: O(1)
193
235
  *
194
236
  * The function calculates the balance factor of a node in a binary tree.
195
- * @param {NODE} node - The parameter "node" is of type "NODE", which likely represents a node in a
237
+ * @param {AVLTreeNode<K, V>} node - The parameter "node" is of type "AVLTreeNode<K, V>", which likely represents a node in a
196
238
  * binary tree data structure.
197
239
  * @returns the balance factor of a given node. The balance factor is calculated by subtracting the
198
240
  * height of the left subtree from the height of the right subtree.
@@ -213,7 +255,7 @@ class AVLTree extends bst_1.BST {
213
255
  *
214
256
  * The function updates the height of a node in a binary tree based on the heights of its left and
215
257
  * right children.
216
- * @param {NODE} node - The parameter "node" represents a node in a binary tree data structure.
258
+ * @param {AVLTreeNode<K, V>} node - The parameter "node" represents a node in a binary tree data structure.
217
259
  */
218
260
  _updateHeight(node) {
219
261
  if (!node.left && !node.right)
@@ -232,12 +274,13 @@ class AVLTree extends bst_1.BST {
232
274
  * Space Complexity: O(1)
233
275
  *
234
276
  * The `_balanceLL` function performs a left-left rotation to balance a binary search tree.
235
- * @param {NODE} A - A is a node in a binary tree.
277
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
236
278
  */
237
279
  _balanceLL(A) {
238
280
  const parentOfA = A.parent;
239
281
  const B = A.left;
240
- A.parent = B;
282
+ if (B !== null)
283
+ A.parent = B;
241
284
  if (B && B.right) {
242
285
  B.right.parent = A;
243
286
  }
@@ -269,7 +312,7 @@ class AVLTree extends bst_1.BST {
269
312
  * Space Complexity: O(1)
270
313
  *
271
314
  * The `_balanceLR` function performs a left-right rotation to balance a binary tree.
272
- * @param {NODE} A - A is a node in a binary tree.
315
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
273
316
  */
274
317
  _balanceLR(A) {
275
318
  const parentOfA = A.parent;
@@ -278,13 +321,14 @@ class AVLTree extends bst_1.BST {
278
321
  if (B) {
279
322
  C = B.right;
280
323
  }
281
- if (A)
324
+ if (A && C !== null)
282
325
  A.parent = C;
283
- if (B)
326
+ if (B && C !== null)
284
327
  B.parent = C;
285
328
  if (C) {
286
329
  if (C.left) {
287
- C.left.parent = B;
330
+ if (B !== null)
331
+ C.left.parent = B;
288
332
  }
289
333
  if (C.right) {
290
334
  C.right.parent = A;
@@ -323,12 +367,13 @@ class AVLTree extends bst_1.BST {
323
367
  * Space Complexity: O(1)
324
368
  *
325
369
  * The function `_balanceRR` performs a right-right rotation to balance a binary tree.
326
- * @param {NODE} A - A is a node in a binary tree.
370
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
327
371
  */
328
372
  _balanceRR(A) {
329
373
  const parentOfA = A.parent;
330
374
  const B = A.right;
331
- A.parent = B;
375
+ if (B !== null)
376
+ A.parent = B;
332
377
  if (B) {
333
378
  if (B.left) {
334
379
  B.left.parent = A;
@@ -362,7 +407,7 @@ class AVLTree extends bst_1.BST {
362
407
  * Space Complexity: O(1)
363
408
  *
364
409
  * The function `_balanceRL` performs a right-left rotation to balance a binary tree.
365
- * @param {NODE} A - A is a node in a binary tree.
410
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
366
411
  */
367
412
  _balanceRL(A) {
368
413
  const parentOfA = A.parent;
@@ -371,15 +416,17 @@ class AVLTree extends bst_1.BST {
371
416
  if (B) {
372
417
  C = B.left;
373
418
  }
374
- A.parent = C;
375
- if (B)
419
+ if (C !== null)
420
+ A.parent = C;
421
+ if (B && C !== null)
376
422
  B.parent = C;
377
423
  if (C) {
378
424
  if (C.left) {
379
425
  C.left.parent = A;
380
426
  }
381
427
  if (C.right) {
382
- C.right.parent = B;
428
+ if (B !== null)
429
+ C.right.parent = B;
383
430
  }
384
431
  C.parent = parentOfA;
385
432
  }
@@ -417,8 +464,8 @@ class AVLTree extends bst_1.BST {
417
464
  *
418
465
  * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
419
466
  * to restore balance in an AVL tree after inserting a node.
420
- * @param {BTNRep<K, V, NODE> | R} node - The `node` parameter can be of type `R` or
421
- * `BTNRep<K, V, NODE>`.
467
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} node - The `node` parameter can be of type `R` or
468
+ * `BTNRep<K, V, AVLTreeNode<K, V>>`.
422
469
  */
423
470
  _balancePath(node) {
424
471
  node = this.ensureNode(node);
@@ -468,9 +515,9 @@ class AVLTree extends bst_1.BST {
468
515
  *
469
516
  * The function replaces an old node with a new node and sets the height of the new node to be the
470
517
  * same as the old node.
471
- * @param {NODE} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
518
+ * @param {AVLTreeNode<K, V>} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
472
519
  * the data structure.
473
- * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
520
+ * @param {AVLTreeNode<K, V>} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
474
521
  * the data structure.
475
522
  * @returns The method is returning the result of calling the `_replaceNode` method from the
476
523
  * superclass, with the `oldNode` and `newNode` as arguments.
@@ -1,3 +1,6 @@
1
+ /**
2
+ *
3
+ */
1
4
  export declare class BinaryIndexedTree {
2
5
  protected readonly _freq: number;
3
6
  protected readonly _max: number;
@@ -9,6 +9,9 @@ exports.BinaryIndexedTree = void 0;
9
9
  * @license MIT License
10
10
  */
11
11
  const utils_1 = require("../../utils");
12
+ /**
13
+ *
14
+ */
12
15
  class BinaryIndexedTree {
13
16
  /**
14
17
  * The constructor initializes the properties of an object, including default frequency, maximum