min-heap-typed 1.42.8 → 1.42.9

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 (49) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +88 -23
  2. package/dist/data-structures/binary-tree/avl-tree.js +88 -23
  3. package/dist/data-structures/binary-tree/binary-tree.d.ts +180 -74
  4. package/dist/data-structures/binary-tree/binary-tree.js +388 -201
  5. package/dist/data-structures/binary-tree/bst.d.ts +121 -66
  6. package/dist/data-structures/binary-tree/bst.js +121 -67
  7. package/dist/data-structures/binary-tree/rb-tree.d.ts +72 -5
  8. package/dist/data-structures/binary-tree/rb-tree.js +95 -18
  9. package/dist/data-structures/binary-tree/tree-multimap.d.ts +82 -43
  10. package/dist/data-structures/binary-tree/tree-multimap.js +82 -43
  11. package/dist/data-structures/graph/abstract-graph.d.ts +139 -36
  12. package/dist/data-structures/graph/abstract-graph.js +147 -36
  13. package/dist/data-structures/graph/directed-graph.d.ts +126 -0
  14. package/dist/data-structures/graph/directed-graph.js +126 -0
  15. package/dist/data-structures/graph/undirected-graph.d.ts +63 -0
  16. package/dist/data-structures/graph/undirected-graph.js +63 -0
  17. package/dist/data-structures/heap/heap.d.ts +175 -12
  18. package/dist/data-structures/heap/heap.js +175 -12
  19. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +203 -0
  20. package/dist/data-structures/linked-list/doubly-linked-list.js +203 -0
  21. package/dist/data-structures/linked-list/singly-linked-list.d.ts +182 -0
  22. package/dist/data-structures/linked-list/singly-linked-list.js +182 -0
  23. package/dist/data-structures/linked-list/skip-linked-list.d.ts +64 -0
  24. package/dist/data-structures/linked-list/skip-linked-list.js +64 -0
  25. package/dist/data-structures/queue/deque.d.ts +113 -3
  26. package/dist/data-structures/queue/deque.js +113 -3
  27. package/dist/data-structures/queue/queue.d.ts +87 -0
  28. package/dist/data-structures/queue/queue.js +87 -0
  29. package/dist/data-structures/stack/stack.d.ts +42 -0
  30. package/dist/data-structures/stack/stack.js +42 -0
  31. package/dist/data-structures/trie/trie.d.ts +76 -0
  32. package/dist/data-structures/trie/trie.js +76 -1
  33. package/package.json +2 -2
  34. package/src/data-structures/binary-tree/avl-tree.ts +97 -23
  35. package/src/data-structures/binary-tree/binary-tree.ts +419 -204
  36. package/src/data-structures/binary-tree/bst.ts +130 -68
  37. package/src/data-structures/binary-tree/rb-tree.ts +106 -19
  38. package/src/data-structures/binary-tree/tree-multimap.ts +88 -44
  39. package/src/data-structures/graph/abstract-graph.ts +133 -7
  40. package/src/data-structures/graph/directed-graph.ts +145 -1
  41. package/src/data-structures/graph/undirected-graph.ts +72 -0
  42. package/src/data-structures/heap/heap.ts +201 -12
  43. package/src/data-structures/linked-list/doubly-linked-list.ts +232 -0
  44. package/src/data-structures/linked-list/singly-linked-list.ts +208 -0
  45. package/src/data-structures/linked-list/skip-linked-list.ts +74 -0
  46. package/src/data-structures/queue/deque.ts +127 -3
  47. package/src/data-structures/queue/queue.ts +99 -0
  48. package/src/data-structures/stack/stack.ts +48 -0
  49. package/src/data-structures/trie/trie.ts +87 -4
@@ -20,6 +20,11 @@ export declare class RedBlackTreeNode<V = any, N extends RedBlackTreeNode<V, N>
20
20
  * 5. Black balance: Every path from any node to each of its leaf nodes contains the same number of black nodes.
21
21
  */
22
22
  export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = RedBlackTreeNode<V, RedBlackTreeNodeNested<V>>> extends BST<V, N> implements IBinaryTree<V, N> {
23
+ /**
24
+ * The constructor function initializes a Red-Black Tree with an optional set of options.
25
+ * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
26
+ * passed to the constructor. It is used to configure the RBTree object with specific options.
27
+ */
23
28
  constructor(options?: RBTreeOptions);
24
29
  protected _root: N;
25
30
  get root(): N;
@@ -27,6 +32,13 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
27
32
  get size(): number;
28
33
  NIL: N;
29
34
  /**
35
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
36
+ * Space Complexity: O(1)
37
+ */
38
+ /**
39
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
40
+ * Space Complexity: O(1)
41
+ *
30
42
  * The `add` function adds a new node to a Red-Black Tree data structure.
31
43
  * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
32
44
  * following types:
@@ -37,6 +49,13 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
37
49
  add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | undefined;
38
50
  createNode(key: BTNKey, value?: V, color?: RBTNColor): N;
39
51
  /**
52
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
53
+ * Space Complexity: O(1)
54
+ */
55
+ /**
56
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
57
+ * Space Complexity: O(1)
58
+ *
40
59
  * The `delete` function removes a node from a binary tree based on a given identifier and updates
41
60
  * the tree accordingly.
42
61
  * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the value
@@ -54,12 +73,26 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
54
73
  getNode<C extends BTNCallback<N, N>>(identifier: N | undefined, callback?: C, beginRoot?: N | undefined, iterationType?: IterationType): N | undefined;
55
74
  getNode<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: N | undefined, iterationType?: IterationType): N | undefined;
56
75
  /**
76
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
77
+ * Space Complexity: O(1)
78
+ */
79
+ /**
80
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
81
+ * Space Complexity: O(1)
82
+ *
57
83
  * The function returns the successor of a given node in a red-black tree.
58
84
  * @param {RedBlackTreeNode} x - RedBlackTreeNode - The node for which we want to find the successor.
59
85
  * @returns the successor of the given RedBlackTreeNode.
60
86
  */
61
87
  getSuccessor(x: N): N | undefined;
62
88
  /**
89
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
90
+ * Space Complexity: O(1)
91
+ */
92
+ /**
93
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
94
+ * Space Complexity: O(1)
95
+ *
63
96
  * The function returns the predecessor of a given node in a red-black tree.
64
97
  * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a
65
98
  * Red-Black Tree.
@@ -69,29 +102,63 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
69
102
  clear(): void;
70
103
  protected _setRoot(v: N): void;
71
104
  /**
72
- * The function performs a left rotation on a red-black tree node.
73
- * @param {RedBlackTreeNode} x - The parameter `x` is a RedBlackTreeNode object.
105
+ * Time Complexity: O(1)
106
+ * Space Complexity: O(1)
107
+ */
108
+ /**
109
+ * Time Complexity: O(1)
110
+ * Space Complexity: O(1)
111
+ *
112
+ * The function performs a left rotation on a binary tree node.
113
+ * @param {RedBlackTreeNode} x - The parameter `x` is of type `N`, which likely represents a node in a binary tree.
74
114
  */
75
115
  protected _leftRotate(x: N): void;
76
116
  /**
117
+ * Time Complexity: O(1)
118
+ * Space Complexity: O(1)
119
+ */
120
+ /**
121
+ * Time Complexity: O(1)
122
+ * Space Complexity: O(1)
123
+ *
77
124
  * The function performs a right rotation on a red-black tree node.
78
125
  * @param {RedBlackTreeNode} x - x is a RedBlackTreeNode, which represents the node that needs to be right
79
126
  * rotated.
80
127
  */
81
128
  protected _rightRotate(x: N): void;
82
129
  /**
83
- * The _fixDelete function is used to rebalance the Red-Black Tree after a node deletion.
84
- * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a
85
- * red-black tree.
130
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
131
+ * Space Complexity: O(1)
132
+ */
133
+ /**
134
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
135
+ * Space Complexity: O(1)
136
+ *
137
+ * The function `_fixDelete` is used to fix the red-black tree after a node deletion.
138
+ * @param {RedBlackTreeNode} x - The parameter `x` represents a node in a Red-Black Tree (RBT).
86
139
  */
87
140
  protected _fixDelete(x: N): void;
88
141
  /**
142
+ * Time Complexity: O(1)
143
+ * Space Complexity: O(1)
144
+ */
145
+ /**
146
+ * Time Complexity: O(1)
147
+ * Space Complexity: O(1)
148
+ *
89
149
  * The function `_rbTransplant` replaces one node in a red-black tree with another node.
90
150
  * @param {RedBlackTreeNode} u - The parameter "u" represents a RedBlackTreeNode object.
91
151
  * @param {RedBlackTreeNode} v - The parameter "v" is a RedBlackTreeNode object.
92
152
  */
93
153
  protected _rbTransplant(u: N, v: N): void;
94
154
  /**
155
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
156
+ * Space Complexity: O(1)
157
+ */
158
+ /**
159
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
160
+ * Space Complexity: O(1)
161
+ *
95
162
  * The `_fixInsert` function is used to fix the red-black tree after an insertion operation.
96
163
  * @param {RedBlackTreeNode} k - The parameter `k` is a RedBlackTreeNode object, which represents a node in a
97
164
  * red-black tree.
@@ -26,6 +26,11 @@ exports.RedBlackTreeNode = RedBlackTreeNode;
26
26
  * 5. Black balance: Every path from any node to each of its leaf nodes contains the same number of black nodes.
27
27
  */
28
28
  class RedBlackTree extends bst_1.BST {
29
+ /**
30
+ * The constructor function initializes a Red-Black Tree with an optional set of options.
31
+ * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
32
+ * passed to the constructor. It is used to configure the RBTree object with specific options.
33
+ */
29
34
  constructor(options) {
30
35
  super(options);
31
36
  this._size = 0;
@@ -39,6 +44,13 @@ class RedBlackTree extends bst_1.BST {
39
44
  return this._size;
40
45
  }
41
46
  /**
47
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
48
+ * Space Complexity: O(1)
49
+ */
50
+ /**
51
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
52
+ * Space Complexity: O(1)
53
+ *
42
54
  * The `add` function adds a new node to a Red-Black Tree data structure.
43
55
  * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
44
56
  * following types:
@@ -102,6 +114,13 @@ class RedBlackTree extends bst_1.BST {
102
114
  return new RedBlackTreeNode(key, value, color);
103
115
  }
104
116
  /**
117
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
118
+ * Space Complexity: O(1)
119
+ */
120
+ /**
121
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
122
+ * Space Complexity: O(1)
123
+ *
105
124
  * The `delete` function removes a node from a binary tree based on a given identifier and updates
106
125
  * the tree accordingly.
107
126
  * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the value
@@ -175,19 +194,29 @@ class RedBlackTree extends bst_1.BST {
175
194
  return node !== this.NIL && node !== undefined;
176
195
  }
177
196
  /**
178
- * The function `get` returns the first node in a binary tree that matches the given property or key.
179
- * @param {BTNKey | N} identifier - The `identifier` parameter is the key or value of
180
- * the node that you want to find in the binary tree. It can be either a `BTNKey` or `N`
181
- * type.
182
- * @param callback - The `callback` parameter is a function that is used to determine whether a node
183
- * matches the desired criteria. It takes a node as input and returns a boolean value indicating
184
- * whether the node matches the criteria or not. The default callback function
185
- * (`this._defaultOneParamCallback`) is used if no callback function is
186
- * @param beginRoot - The `beginRoot` parameter is the starting point for the search. It specifies
187
- * the root node from which the search should begin.
188
- * @param iterationType - The `iterationType` parameter specifies the type of iteration to be
189
- * performed when searching for a node in the binary tree. It can have one of the following values:
190
- * @returns either the found node (of type N) or null if no node is found.
197
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
198
+ * Space Complexity: O(1)
199
+ */
200
+ /**
201
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
202
+ * Space Complexity: O(1)
203
+ *
204
+ * The function `getNode` retrieves a single node from a binary tree based on a given identifier and
205
+ * callback function.
206
+ * @param {ReturnType<C> | undefined} identifier - The `identifier` parameter is the value used to
207
+ * identify the node you want to retrieve. It can be of any type that is the return type of the `C`
208
+ * callback function. If the `identifier` is `undefined`, it means you want to retrieve the first
209
+ * node that matches the other criteria
210
+ * @param {C} callback - The `callback` parameter is a function that will be called for each node in
211
+ * the binary tree. It is used to determine if a node matches the given identifier. The `callback`
212
+ * function should take a single parameter of type `N` (the type of the nodes in the binary tree) and
213
+ * @param {BTNKey | N | undefined} beginRoot - The `beginRoot` parameter is the starting point for
214
+ * searching for a node in a binary tree. It can be either a key value or a node object. If it is not
215
+ * provided, the search will start from the root of the binary tree.
216
+ * @param iterationType - The `iterationType` parameter is a variable that determines the type of
217
+ * iteration to be performed when searching for nodes in the binary tree. It is used in the
218
+ * `getNodes` method, which is called within the `getNode` method.
219
+ * @returns a value of type `N`, `null`, or `undefined`.
191
220
  */
192
221
  getNode(identifier, callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
193
222
  var _a;
@@ -197,6 +226,13 @@ class RedBlackTree extends bst_1.BST {
197
226
  return (_a = this.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) !== null && _a !== void 0 ? _a : undefined;
198
227
  }
199
228
  /**
229
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
230
+ * Space Complexity: O(1)
231
+ */
232
+ /**
233
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
234
+ * Space Complexity: O(1)
235
+ *
200
236
  * The function returns the successor of a given node in a red-black tree.
201
237
  * @param {RedBlackTreeNode} x - RedBlackTreeNode - The node for which we want to find the successor.
202
238
  * @returns the successor of the given RedBlackTreeNode.
@@ -214,6 +250,13 @@ class RedBlackTree extends bst_1.BST {
214
250
  return y;
215
251
  }
216
252
  /**
253
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
254
+ * Space Complexity: O(1)
255
+ */
256
+ /**
257
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
258
+ * Space Complexity: O(1)
259
+ *
217
260
  * The function returns the predecessor of a given node in a red-black tree.
218
261
  * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a
219
262
  * Red-Black Tree.
@@ -241,8 +284,15 @@ class RedBlackTree extends bst_1.BST {
241
284
  this._root = v;
242
285
  }
243
286
  /**
244
- * The function performs a left rotation on a red-black tree node.
245
- * @param {RedBlackTreeNode} x - The parameter `x` is a RedBlackTreeNode object.
287
+ * Time Complexity: O(1)
288
+ * Space Complexity: O(1)
289
+ */
290
+ /**
291
+ * Time Complexity: O(1)
292
+ * Space Complexity: O(1)
293
+ *
294
+ * The function performs a left rotation on a binary tree node.
295
+ * @param {RedBlackTreeNode} x - The parameter `x` is of type `N`, which likely represents a node in a binary tree.
246
296
  */
247
297
  _leftRotate(x) {
248
298
  if (x.right) {
@@ -267,6 +317,13 @@ class RedBlackTree extends bst_1.BST {
267
317
  }
268
318
  }
269
319
  /**
320
+ * Time Complexity: O(1)
321
+ * Space Complexity: O(1)
322
+ */
323
+ /**
324
+ * Time Complexity: O(1)
325
+ * Space Complexity: O(1)
326
+ *
270
327
  * The function performs a right rotation on a red-black tree node.
271
328
  * @param {RedBlackTreeNode} x - x is a RedBlackTreeNode, which represents the node that needs to be right
272
329
  * rotated.
@@ -294,9 +351,15 @@ class RedBlackTree extends bst_1.BST {
294
351
  }
295
352
  }
296
353
  /**
297
- * The _fixDelete function is used to rebalance the Red-Black Tree after a node deletion.
298
- * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a
299
- * red-black tree.
354
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
355
+ * Space Complexity: O(1)
356
+ */
357
+ /**
358
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
359
+ * Space Complexity: O(1)
360
+ *
361
+ * The function `_fixDelete` is used to fix the red-black tree after a node deletion.
362
+ * @param {RedBlackTreeNode} x - The parameter `x` represents a node in a Red-Black Tree (RBT).
300
363
  */
301
364
  _fixDelete(x) {
302
365
  let s;
@@ -363,6 +426,13 @@ class RedBlackTree extends bst_1.BST {
363
426
  x.color = types_1.RBTNColor.BLACK;
364
427
  }
365
428
  /**
429
+ * Time Complexity: O(1)
430
+ * Space Complexity: O(1)
431
+ */
432
+ /**
433
+ * Time Complexity: O(1)
434
+ * Space Complexity: O(1)
435
+ *
366
436
  * The function `_rbTransplant` replaces one node in a red-black tree with another node.
367
437
  * @param {RedBlackTreeNode} u - The parameter "u" represents a RedBlackTreeNode object.
368
438
  * @param {RedBlackTreeNode} v - The parameter "v" is a RedBlackTreeNode object.
@@ -380,6 +450,13 @@ class RedBlackTree extends bst_1.BST {
380
450
  v.parent = u.parent;
381
451
  }
382
452
  /**
453
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
454
+ * Space Complexity: O(1)
455
+ */
456
+ /**
457
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
458
+ * Space Complexity: O(1)
459
+ *
383
460
  * The `_fixInsert` function is used to fix the red-black tree after an insertion operation.
384
461
  * @param {RedBlackTreeNode} k - The parameter `k` is a RedBlackTreeNode object, which represents a node in a
385
462
  * red-black tree.
@@ -47,63 +47,100 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
47
47
  */
48
48
  createNode(key: BTNKey, value?: V, count?: number): N;
49
49
  /**
50
- * The `add` function adds a new node to a binary search tree, updating the count if the key already
51
- * exists, and balancing the tree if necessary.
52
- * @param {BTNKey | N | undefined} keyOrNode - The `keyOrNode` parameter can be either a
53
- * `BTNKey` (which represents the key of the node to be added), a `N` (which represents a
54
- * node to be added), or `undefined` (which represents a undefined node).
55
- * @param [value] - The `value` parameter represents the value associated with the key that is being
56
- * added to the binary tree.
57
- * @param [count=1] - The `count` parameter represents the number of occurrences of the key/value
58
- * pair that will be added to the binary tree. It has a default value of 1, which means that if no
59
- * count is specified, the default count will be 1.
60
- * @returns The function `add` returns a value of type `N | undefined | undefined`.
50
+ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.
51
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
52
+ */
53
+ /**
54
+ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.
55
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
56
+ *
57
+ * The `add` function adds a new node to the tree multimap, updating the count if the key already
58
+ * exists, and balances the tree if necessary.
59
+ * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
60
+ * following types:
61
+ * @param {V} [value] - The `value` parameter represents the value associated with the key that is
62
+ * being added to the tree. It is an optional parameter, so it can be omitted if not needed.
63
+ * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
64
+ * times the key-value pair should be added to the multimap. If not provided, the default value is 1.
65
+ * @returns a node (`N`) or `undefined`.
61
66
  */
62
67
  add(keyOrNode: BTNKey | N | null | undefined, value?: V, count?: number): N | undefined;
63
68
  /**
64
- * The function adds a new node to a binary tree if there is an available slot in the parent node.
65
- * @param {N | undefined} newNode - The `newNode` parameter represents the node that needs to be added to
66
- * the tree. It can be either a node object (`N`) or `undefined`.
67
- * @param {N} parent - The `parent` parameter represents the parent node to which the new node will
68
- * be added as a child.
69
- * @returns The method `_addTo` returns either the `parent.left`, `parent.right`, or `undefined`.
69
+ * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
70
+ * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
71
+ */
72
+ /**
73
+ * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
74
+ * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
75
+ *
76
+ * The function adds a new node to a binary tree, either as the left child or the right child of a
77
+ * given parent node.
78
+ * @param {N | undefined} newNode - The `newNode` parameter represents the node that needs to be
79
+ * added to the binary tree. It can be of type `N` (which represents a node in the binary tree) or
80
+ * `undefined` if there is no node to add.
81
+ * @param {BTNKey | N | undefined} parent - The `parent` parameter represents the parent node to
82
+ * which the new node will be added as a child. It can be either a node object (`N`) or a key value
83
+ * (`BTNKey`).
84
+ * @returns The method `_addTo` returns either the `parent.left` or `parent.right` node that was
85
+ * added, or `undefined` if no node was added.
70
86
  */
71
87
  protected _addTo(newNode: N | undefined, parent: BTNKey | N | undefined): N | undefined;
72
88
  /**
73
- * The `addMany` function adds multiple keys or nodes to a TreeMultimap and returns an array of the
74
- * inserted nodes.
75
- * @param {(BTNKey | undefined)[] | (N | undefined)[]} keysOrNodes - An array of keys or nodes to be
76
- * added to the multiset. Each element can be either a BTNKey or a TreeMultimapNode.
77
- * @param {V[]} [data] - The `data` parameter is an optional array of values that correspond
78
- * to the keys or nodes being added to the multiset. It is used to associate additional data with
79
- * each key or node.
80
- * @returns The function `addMany` returns an array of `N`, `undefined`, or `undefined` values.
89
+ * Time Complexity: O(k log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each.
90
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
91
+ */
92
+ /**
93
+ * Time Complexity: O(k log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each.
94
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
95
+ *
96
+ * The function `addMany` takes an array of keys or nodes and adds them to the TreeMultimap,
97
+ * returning an array of the inserted nodes.
98
+ * @param {(BTNKey | N | undefined)[]} keysOrNodes - An array of keys or nodes. Each element can be
99
+ * of type BTNKey, N, or undefined.
100
+ * @param {V[]} [data] - The `data` parameter is an optional array of values that correspond to the
101
+ * keys or nodes being added. It is used to associate data with each key or node being added to the
102
+ * TreeMultimap. If provided, the length of the `data` array should be the same as the length of the
103
+ * @returns The function `addMany` returns an array of nodes (`N`) or `undefined` values.
81
104
  */
82
105
  addMany(keysOrNodes: (BTNKey | N | undefined)[], data?: V[]): (N | undefined)[];
83
106
  /**
84
- * The `perfectlyBalance` function in TypeScript takes a sorted array of nodes and builds a balanced
85
- * binary search tree using either a recursive or iterative approach.
107
+ * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
108
+ * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
109
+ */
110
+ /**
111
+ * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
112
+ * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
113
+ *
114
+ * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
115
+ * tree using either a recursive or iterative approach.
86
116
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
87
- * type of iteration to use when building a balanced binary search tree. It can have two possible
117
+ * type of iteration to use when building the balanced binary search tree. It can have two possible
88
118
  * values:
89
119
  * @returns a boolean value.
90
120
  */
91
121
  perfectlyBalance(iterationType?: IterationType): boolean;
92
122
  /**
93
- * The `delete` function in a binary search tree deletes a node from the tree and returns the deleted
94
- * node along with the parent node that needs to be balanced.
95
- * @param {ReturnType<C>} identifier - The `identifier` parameter is either a
96
- * `BTNKey` or a generic type `N`. It represents the property of the node that we are
97
- * searching for. It can be a specific key value or any other property of the node.
98
- * @param callback - The `callback` parameter is a function that takes a node as input and returns a
99
- * value. This value is compared with the `identifier` parameter to determine if the node should be
100
- * included in the result. The `callback` parameter has a default value of
101
- * `this._defaultOneParamCallback`
123
+ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (AVLTree) has logarithmic time complexity.
124
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
125
+ */
126
+ /**
127
+ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (AVLTree) has logarithmic time complexity.
128
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
129
+ *
130
+ * The `delete` function in TypeScript is used to remove a node from a binary tree, taking into
131
+ * account the count of the node and balancing the tree if necessary.
132
+ * @param identifier - The identifier is the value or key that is used to identify the node that
133
+ * needs to be deleted from the binary tree. It can be of any type that is returned by the callback
134
+ * function.
135
+ * @param {C} callback - The `callback` parameter is a function that is used to determine if a node
136
+ * should be deleted. It is optional and defaults to a default callback function. The `callback`
137
+ * function takes one parameter, which is the identifier of the node, and returns a value that is
138
+ * used to identify the node to
102
139
  * @param [ignoreCount=false] - A boolean flag indicating whether to ignore the count of the node
103
140
  * being deleted. If set to true, the count of the node will not be considered and the node will be
104
141
  * deleted regardless of its count. If set to false (default), the count of the node will be
105
142
  * decremented by 1 and
106
- * @returns The method `delete` returns an array of `BiTreeDeleteResult<N>` objects.
143
+ * @returns an array of `BiTreeDeleteResult<N>`.
107
144
  */
108
145
  delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BiTreeDeleteResult<N>[];
109
146
  /**
@@ -111,11 +148,13 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
111
148
  */
112
149
  clear(): void;
113
150
  /**
114
- * The function swaps the values of two nodes in a binary tree.
115
- * @param {N} srcNode - The source node that needs to be swapped with the destination node.
116
- * @param {N} destNode - The `destNode` parameter represents the destination node where the values
117
- * from `srcNode` will be swapped into.
118
- * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
151
+ * The `_swap` function swaps the key, value, count, and height properties between two nodes.
152
+ * @param {BTNKey | N | undefined} srcNode - The `srcNode` parameter represents the source node from
153
+ * which the values will be swapped. It can be of type `BTNKey`, `N`, or `undefined`.
154
+ * @param {BTNKey | N | undefined} destNode - The `destNode` parameter represents the destination
155
+ * node where the values from the source node will be swapped to.
156
+ * @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
157
+ * if either `srcNode` or `destNode` is undefined.
119
158
  */
120
159
  protected _swap(srcNode: BTNKey | N | undefined, destNode: BTNKey | N | undefined): N | undefined;
121
160
  }