min-heap-typed 1.50.0 → 1.50.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.
Files changed (67) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +114 -9
  2. package/dist/data-structures/base/iterable-base.js +143 -7
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +43 -46
  4. package/dist/data-structures/binary-tree/avl-tree.js +68 -71
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +244 -199
  6. package/dist/data-structures/binary-tree/binary-tree.js +484 -376
  7. package/dist/data-structures/binary-tree/bst.d.ts +54 -74
  8. package/dist/data-structures/binary-tree/bst.js +30 -71
  9. package/dist/data-structures/binary-tree/rb-tree.d.ts +78 -60
  10. package/dist/data-structures/binary-tree/rb-tree.js +84 -89
  11. package/dist/data-structures/binary-tree/tree-multimap.d.ts +37 -56
  12. package/dist/data-structures/binary-tree/tree-multimap.js +64 -85
  13. package/dist/data-structures/graph/abstract-graph.d.ts +1 -0
  14. package/dist/data-structures/graph/abstract-graph.js +3 -0
  15. package/dist/data-structures/graph/directed-graph.d.ts +14 -0
  16. package/dist/data-structures/graph/directed-graph.js +26 -0
  17. package/dist/data-structures/graph/map-graph.d.ts +8 -0
  18. package/dist/data-structures/graph/map-graph.js +14 -0
  19. package/dist/data-structures/graph/undirected-graph.d.ts +16 -0
  20. package/dist/data-structures/graph/undirected-graph.js +25 -0
  21. package/dist/data-structures/hash/hash-map.d.ts +121 -15
  22. package/dist/data-structures/hash/hash-map.js +160 -25
  23. package/dist/data-structures/heap/heap.d.ts +66 -6
  24. package/dist/data-structures/heap/heap.js +66 -6
  25. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +67 -50
  26. package/dist/data-structures/linked-list/doubly-linked-list.js +70 -64
  27. package/dist/data-structures/linked-list/singly-linked-list.d.ts +128 -103
  28. package/dist/data-structures/linked-list/singly-linked-list.js +130 -112
  29. package/dist/data-structures/linked-list/skip-linked-list.d.ts +63 -36
  30. package/dist/data-structures/linked-list/skip-linked-list.js +63 -36
  31. package/dist/data-structures/matrix/matrix.d.ts +35 -4
  32. package/dist/data-structures/matrix/matrix.js +50 -11
  33. package/dist/data-structures/queue/deque.d.ts +49 -19
  34. package/dist/data-structures/queue/deque.js +101 -47
  35. package/dist/data-structures/queue/queue.d.ts +39 -5
  36. package/dist/data-structures/queue/queue.js +47 -5
  37. package/dist/data-structures/stack/stack.d.ts +16 -0
  38. package/dist/data-structures/stack/stack.js +22 -0
  39. package/dist/data-structures/trie/trie.d.ts +38 -1
  40. package/dist/data-structures/trie/trie.js +41 -0
  41. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  42. package/dist/types/data-structures/hash/hash-map.d.ts +4 -3
  43. package/dist/types/utils/utils.d.ts +1 -0
  44. package/package.json +2 -2
  45. package/src/data-structures/base/iterable-base.ts +172 -19
  46. package/src/data-structures/binary-tree/avl-tree.ts +97 -97
  47. package/src/data-structures/binary-tree/binary-tree.ts +674 -671
  48. package/src/data-structures/binary-tree/bst.ts +89 -131
  49. package/src/data-structures/binary-tree/rb-tree.ts +127 -155
  50. package/src/data-structures/binary-tree/tree-multimap.ts +96 -112
  51. package/src/data-structures/graph/abstract-graph.ts +4 -0
  52. package/src/data-structures/graph/directed-graph.ts +30 -0
  53. package/src/data-structures/graph/map-graph.ts +15 -0
  54. package/src/data-structures/graph/undirected-graph.ts +28 -0
  55. package/src/data-structures/hash/hash-map.ts +175 -34
  56. package/src/data-structures/heap/heap.ts +66 -6
  57. package/src/data-structures/linked-list/doubly-linked-list.ts +72 -66
  58. package/src/data-structures/linked-list/singly-linked-list.ts +132 -114
  59. package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
  60. package/src/data-structures/matrix/matrix.ts +52 -12
  61. package/src/data-structures/queue/deque.ts +108 -49
  62. package/src/data-structures/queue/queue.ts +51 -5
  63. package/src/data-structures/stack/stack.ts +24 -0
  64. package/src/data-structures/trie/trie.ts +45 -1
  65. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  66. package/src/types/data-structures/hash/hash-map.ts +4 -3
  67. package/src/types/utils/utils.ts +2 -0
@@ -105,6 +105,72 @@ export declare abstract class IterableEntryBase<K = any, V = any> {
105
105
  * used as the `this` value when calling the callback function. If `thisArg` is not provided, `
106
106
  */
107
107
  forEach(callbackfn: EntryCallback<K, V, void>, thisArg?: any): void;
108
+ /**
109
+ * Time Complexity: O(n)
110
+ * Space Complexity: O(1)
111
+ */
112
+ /**
113
+ * Time Complexity: O(n)
114
+ * Space Complexity: O(1)
115
+ *
116
+ * The `find` function iterates over the entries of a collection and returns the first value for
117
+ * which the callback function returns true.
118
+ * @param callbackfn - The callback function that will be called for each entry in the collection. It
119
+ * takes three arguments: the value of the entry, the key of the entry, and the index of the entry in
120
+ * the collection. It should return a boolean value indicating whether the current entry matches the
121
+ * desired condition.
122
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
123
+ * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
124
+ * be passed as the `this` value to the `callbackfn` function. If `thisArg
125
+ * @returns The method `find` returns the value of the first element in the iterable that satisfies
126
+ * the provided callback function. If no element satisfies the callback function, `undefined` is
127
+ * returned.
128
+ */
129
+ find(callbackfn: EntryCallback<K, V, [K, V]>, thisArg?: any): [K, V] | undefined;
130
+ /**
131
+ * Time Complexity: O(n)
132
+ * Space Complexity: O(1)
133
+ */
134
+ /**
135
+ * Time Complexity: O(n)
136
+ * Space Complexity: O(1)
137
+ *
138
+ * The function checks if a given key exists in a collection.
139
+ * @param {K} key - The parameter "key" is of type K, which means it can be any type. It represents
140
+ * the key that we want to check for existence in the data structure.
141
+ * @returns a boolean value. It returns true if the key is found in the collection, and false
142
+ * otherwise.
143
+ */
144
+ has(key: K): boolean;
145
+ /**
146
+ * Time Complexity: O(n)
147
+ * Space Complexity: O(1)
148
+ */
149
+ /**
150
+ * Time Complexity: O(n)
151
+ * Space Complexity: O(1)
152
+ *
153
+ * The function checks if a given value exists in a collection.
154
+ * @param {V} value - The parameter "value" is the value that we want to check if it exists in the
155
+ * collection.
156
+ * @returns a boolean value, either true or false.
157
+ */
158
+ hasValue(value: V): boolean;
159
+ /**
160
+ * Time Complexity: O(n)
161
+ * Space Complexity: O(1)
162
+ */
163
+ /**
164
+ * Time Complexity: O(n)
165
+ * Space Complexity: O(1)
166
+ *
167
+ * The `get` function retrieves the value associated with a given key from a collection.
168
+ * @param {K} key - K (the type of the key) - This parameter represents the key that is being
169
+ * searched for in the collection.
170
+ * @returns The `get` method returns the value associated with the specified key if it exists in the
171
+ * collection, otherwise it returns `undefined`.
172
+ */
173
+ get(key: K): V | undefined;
108
174
  /**
109
175
  * Time Complexity: O(n)
110
176
  * Space Complexity: O(1)
@@ -126,15 +192,16 @@ export declare abstract class IterableEntryBase<K = any, V = any> {
126
192
  * all the elements in the collection.
127
193
  */
128
194
  reduce<U>(callbackfn: ReduceEntryCallback<K, V, U>, initialValue: U): U;
129
- hasValue(value: V): boolean;
130
195
  /**
131
196
  * Time Complexity: O(n)
132
197
  * Space Complexity: O(n)
133
198
  */
134
199
  print(): void;
200
+ abstract isEmpty(): boolean;
201
+ abstract clone(): any;
135
202
  protected abstract _getIterator(...args: any[]): IterableIterator<[K, V]>;
136
203
  }
137
- export declare abstract class IterableElementBase<V> {
204
+ export declare abstract class IterableElementBase<E = any, C = any> {
138
205
  /**
139
206
  * Time Complexity: O(n)
140
207
  * Space Complexity: O(1)
@@ -148,7 +215,7 @@ export declare abstract class IterableElementBase<V> {
148
215
  * allows the function to accept any number of arguments as an array. In this case, the `args`
149
216
  * parameter is used to pass any number of arguments to the `_getIterator` method.
150
217
  */
151
- [Symbol.iterator](...args: any[]): IterableIterator<V>;
218
+ [Symbol.iterator](...args: any[]): IterableIterator<E>;
152
219
  /**
153
220
  * Time Complexity: O(n)
154
221
  * Space Complexity: O(n)
@@ -159,7 +226,7 @@ export declare abstract class IterableElementBase<V> {
159
226
  *
160
227
  * The function returns an iterator that yields all the values in the object.
161
228
  */
162
- values(): IterableIterator<V>;
229
+ values(): IterableIterator<E>;
163
230
  /**
164
231
  * Time Complexity: O(n)
165
232
  * Space Complexity: O(1)
@@ -178,7 +245,7 @@ export declare abstract class IterableElementBase<V> {
178
245
  * @returns The `every` method is returning a boolean value. It returns `true` if every element in
179
246
  * the array satisfies the provided predicate function, and `false` otherwise.
180
247
  */
181
- every(predicate: ElementCallback<V, boolean>, thisArg?: any): boolean;
248
+ every(predicate: ElementCallback<E, boolean>, thisArg?: any): boolean;
182
249
  /**
183
250
  * Time Complexity: O(n)
184
251
  * Space Complexity: O(1)
@@ -197,7 +264,7 @@ export declare abstract class IterableElementBase<V> {
197
264
  * @returns a boolean value. It returns true if the predicate function returns true for any element
198
265
  * in the collection, and false otherwise.
199
266
  */
200
- some(predicate: ElementCallback<V, boolean>, thisArg?: any): boolean;
267
+ some(predicate: ElementCallback<E, boolean>, thisArg?: any): boolean;
201
268
  /**
202
269
  * Time Complexity: O(n)
203
270
  * Space Complexity: O(1)
@@ -215,7 +282,43 @@ export declare abstract class IterableElementBase<V> {
215
282
  * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
216
283
  * be passed as the `this` value to the `callbackfn` function. If `thisArg
217
284
  */
218
- forEach(callbackfn: ElementCallback<V, void>, thisArg?: any): void;
285
+ forEach(callbackfn: ElementCallback<E, void>, thisArg?: any): void;
286
+ /**
287
+ * Time Complexity: O(n)
288
+ * Space Complexity: O(1)
289
+ */
290
+ /**
291
+ * Time Complexity: O(n)
292
+ * Space Complexity: O(1)
293
+ *
294
+ * The `find` function iterates over the elements of an array-like object and returns the first
295
+ * element that satisfies the provided callback function.
296
+ * @param callbackfn - The callbackfn parameter is a function that will be called for each element in
297
+ * the array. It takes three arguments: the current element being processed, the index of the current
298
+ * element, and the array itself. The function should return a boolean value indicating whether the
299
+ * current element matches the desired condition.
300
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
301
+ * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
302
+ * be passed as the `this` value to the `callbackfn` function. If `thisArg
303
+ * @returns The `find` method returns the first element in the array that satisfies the provided
304
+ * callback function. If no element satisfies the callback function, `undefined` is returned.
305
+ */
306
+ find(callbackfn: ElementCallback<E, boolean>, thisArg?: any): E | undefined;
307
+ /**
308
+ * Time Complexity: O(n)
309
+ * Space Complexity: O(1)
310
+ */
311
+ /**
312
+ * Time Complexity: O(n)
313
+ * Space Complexity: O(1)
314
+ *
315
+ * The function checks if a given element exists in a collection.
316
+ * @param {E} element - The parameter "element" is of type E, which means it can be any type. It
317
+ * represents the element that we want to check for existence in the collection.
318
+ * @returns a boolean value. It returns true if the element is found in the collection, and false
319
+ * otherwise.
320
+ */
321
+ has(element: E): boolean;
219
322
  /**
220
323
  * Time Complexity: O(n)
221
324
  * Space Complexity: O(1)
@@ -233,11 +336,13 @@ export declare abstract class IterableElementBase<V> {
233
336
  * @returns The `reduce` method is returning the final value of the accumulator after iterating over
234
337
  * all the elements in the array and applying the callback function to each element.
235
338
  */
236
- reduce<U>(callbackfn: ReduceElementCallback<V, U>, initialValue: U): U;
339
+ reduce<U>(callbackfn: ReduceElementCallback<E, U>, initialValue: U): U;
237
340
  /**
238
341
  * Time Complexity: O(n)
239
342
  * Space Complexity: O(n)
240
343
  */
241
344
  print(): void;
242
- protected abstract _getIterator(...args: any[]): IterableIterator<V>;
345
+ abstract isEmpty(): boolean;
346
+ abstract clone(): C;
347
+ protected abstract _getIterator(...args: any[]): IterableIterator<E>;
243
348
  }
@@ -143,6 +143,100 @@ class IterableEntryBase {
143
143
  callbackfn.call(thisArg, value, key, index++, this);
144
144
  }
145
145
  }
146
+ /**
147
+ * Time Complexity: O(n)
148
+ * Space Complexity: O(1)
149
+ */
150
+ /**
151
+ * Time Complexity: O(n)
152
+ * Space Complexity: O(1)
153
+ *
154
+ * The `find` function iterates over the entries of a collection and returns the first value for
155
+ * which the callback function returns true.
156
+ * @param callbackfn - The callback function that will be called for each entry in the collection. It
157
+ * takes three arguments: the value of the entry, the key of the entry, and the index of the entry in
158
+ * the collection. It should return a boolean value indicating whether the current entry matches the
159
+ * desired condition.
160
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
161
+ * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
162
+ * be passed as the `this` value to the `callbackfn` function. If `thisArg
163
+ * @returns The method `find` returns the value of the first element in the iterable that satisfies
164
+ * the provided callback function. If no element satisfies the callback function, `undefined` is
165
+ * returned.
166
+ */
167
+ find(callbackfn, thisArg) {
168
+ let index = 0;
169
+ for (const item of this) {
170
+ const [key, value] = item;
171
+ if (callbackfn.call(thisArg, value, key, index++, this))
172
+ return item;
173
+ }
174
+ return;
175
+ }
176
+ /**
177
+ * Time Complexity: O(n)
178
+ * Space Complexity: O(1)
179
+ */
180
+ /**
181
+ * Time Complexity: O(n)
182
+ * Space Complexity: O(1)
183
+ *
184
+ * The function checks if a given key exists in a collection.
185
+ * @param {K} key - The parameter "key" is of type K, which means it can be any type. It represents
186
+ * the key that we want to check for existence in the data structure.
187
+ * @returns a boolean value. It returns true if the key is found in the collection, and false
188
+ * otherwise.
189
+ */
190
+ has(key) {
191
+ for (const item of this) {
192
+ const [itemKey] = item;
193
+ if (itemKey === key)
194
+ return true;
195
+ }
196
+ return false;
197
+ }
198
+ /**
199
+ * Time Complexity: O(n)
200
+ * Space Complexity: O(1)
201
+ */
202
+ /**
203
+ * Time Complexity: O(n)
204
+ * Space Complexity: O(1)
205
+ *
206
+ * The function checks if a given value exists in a collection.
207
+ * @param {V} value - The parameter "value" is the value that we want to check if it exists in the
208
+ * collection.
209
+ * @returns a boolean value, either true or false.
210
+ */
211
+ hasValue(value) {
212
+ for (const [, elementValue] of this) {
213
+ if (elementValue === value)
214
+ return true;
215
+ }
216
+ return false;
217
+ }
218
+ /**
219
+ * Time Complexity: O(n)
220
+ * Space Complexity: O(1)
221
+ */
222
+ /**
223
+ * Time Complexity: O(n)
224
+ * Space Complexity: O(1)
225
+ *
226
+ * The `get` function retrieves the value associated with a given key from a collection.
227
+ * @param {K} key - K (the type of the key) - This parameter represents the key that is being
228
+ * searched for in the collection.
229
+ * @returns The `get` method returns the value associated with the specified key if it exists in the
230
+ * collection, otherwise it returns `undefined`.
231
+ */
232
+ get(key) {
233
+ for (const item of this) {
234
+ const [itemKey, value] = item;
235
+ if (itemKey === key)
236
+ return value;
237
+ }
238
+ return;
239
+ }
146
240
  /**
147
241
  * Time Complexity: O(n)
148
242
  * Space Complexity: O(1)
@@ -172,13 +266,6 @@ class IterableEntryBase {
172
266
  }
173
267
  return accumulator;
174
268
  }
175
- hasValue(value) {
176
- for (const [, elementValue] of this) {
177
- if (elementValue === value)
178
- return true;
179
- }
180
- return false;
181
- }
182
269
  /**
183
270
  * Time Complexity: O(n)
184
271
  * Space Complexity: O(n)
@@ -297,6 +384,55 @@ class IterableElementBase {
297
384
  callbackfn.call(thisArg, item, index++, this);
298
385
  }
299
386
  }
387
+ /**
388
+ * Time Complexity: O(n)
389
+ * Space Complexity: O(1)
390
+ */
391
+ /**
392
+ * Time Complexity: O(n)
393
+ * Space Complexity: O(1)
394
+ *
395
+ * The `find` function iterates over the elements of an array-like object and returns the first
396
+ * element that satisfies the provided callback function.
397
+ * @param callbackfn - The callbackfn parameter is a function that will be called for each element in
398
+ * the array. It takes three arguments: the current element being processed, the index of the current
399
+ * element, and the array itself. The function should return a boolean value indicating whether the
400
+ * current element matches the desired condition.
401
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
402
+ * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
403
+ * be passed as the `this` value to the `callbackfn` function. If `thisArg
404
+ * @returns The `find` method returns the first element in the array that satisfies the provided
405
+ * callback function. If no element satisfies the callback function, `undefined` is returned.
406
+ */
407
+ find(callbackfn, thisArg) {
408
+ let index = 0;
409
+ for (const item of this) {
410
+ if (callbackfn.call(thisArg, item, index++, this))
411
+ return item;
412
+ }
413
+ return;
414
+ }
415
+ /**
416
+ * Time Complexity: O(n)
417
+ * Space Complexity: O(1)
418
+ */
419
+ /**
420
+ * Time Complexity: O(n)
421
+ * Space Complexity: O(1)
422
+ *
423
+ * The function checks if a given element exists in a collection.
424
+ * @param {E} element - The parameter "element" is of type E, which means it can be any type. It
425
+ * represents the element that we want to check for existence in the collection.
426
+ * @returns a boolean value. It returns true if the element is found in the collection, and false
427
+ * otherwise.
428
+ */
429
+ has(element) {
430
+ for (const ele of this) {
431
+ if (ele === element)
432
+ return true;
433
+ }
434
+ return false;
435
+ }
300
436
  /**
301
437
  * Time Complexity: O(n)
302
438
  * Space Complexity: O(1)
@@ -8,7 +8,7 @@
8
8
  import { BST, BSTNode } from './bst';
9
9
  import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
- export declare class AVLTreeNode<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, N> {
11
+ export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
12
12
  height: number;
13
13
  constructor(key: K, value?: V);
14
14
  }
@@ -21,27 +21,27 @@ export declare class AVLTreeNode<K = any, V = any, N extends AVLTreeNode<K, V, N
21
21
  * 6. Complex Insertions and Deletions: Due to rebalancing, these operations are more complex than in a regular BST.
22
22
  * 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.
23
23
  */
24
- export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, N, TREE> = AVLTree<K, V, N, AVLTreeNested<K, V, N>>> extends BST<K, V, N, TREE> implements IBinaryTree<K, V, N, TREE> {
24
+ export declare class AVLTree<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, NODE, TREE> = AVLTree<K, V, NODE, AVLTreeNested<K, V, NODE>>> extends BST<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> {
25
25
  /**
26
26
  * The constructor function initializes an AVLTree object with optional keysOrNodesOrEntries and options.
27
- * @param [keysOrNodesOrEntries] - The `keysOrNodesOrEntries` parameter is an optional iterable of `KeyOrNodeOrEntry<K, V, N>`
27
+ * @param [keysOrNodesOrEntries] - The `keysOrNodesOrEntries` parameter is an optional iterable of `KeyOrNodeOrEntry<K, V, NODE>`
28
28
  * objects. It represents a collection of nodes that will be added to the AVL tree during
29
29
  * initialization.
30
30
  * @param [options] - The `options` parameter is an optional object that allows you to customize the
31
31
  * behavior of the AVL tree. It is of type `Partial<AVLTreeOptions>`, which means that you can
32
32
  * provide only a subset of the properties defined in the `AVLTreeOptions` interface.
33
33
  */
34
- constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, N>>, options?: AVLTreeOptions<K>);
34
+ constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeOptions<K>);
35
35
  /**
36
36
  * The function creates a new AVL tree node with the specified key and value.
37
37
  * @param {K} key - The key parameter is the key value that will be associated with
38
38
  * the new node. It is used to determine the position of the node in the binary search tree.
39
39
  * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
40
40
  * type `V`, which means it can be any value that is assignable to the `value` property of the
41
- * node type `N`.
41
+ * node type `NODE`.
42
42
  * @returns a new AVLTreeNode object with the specified key and value.
43
43
  */
44
- createNode(key: K, value?: V): N;
44
+ createNode(key: K, value?: V): NODE;
45
45
  /**
46
46
  * The function creates a new AVL tree with the specified options and returns it.
47
47
  * @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
@@ -52,10 +52,10 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
52
52
  createTree(options?: AVLTreeOptions<K>): TREE;
53
53
  /**
54
54
  * The function checks if an keyOrNodeOrEntry is an instance of AVLTreeNode.
55
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, N>`.
55
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`.
56
56
  * @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the AVLTreeNode class.
57
57
  */
58
- isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>): keyOrNodeOrEntry is N;
58
+ isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE;
59
59
  /**
60
60
  * Time Complexity: O(log n)
61
61
  * Space Complexity: O(1)
@@ -73,7 +73,7 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
73
73
  * being added to the binary tree.
74
74
  * @returns The method is returning either the inserted node or undefined.
75
75
  */
76
- add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, value?: V): boolean;
76
+ add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
77
77
  /**
78
78
  * Time Complexity: O(log n)
79
79
  * Space Complexity: O(1)
@@ -90,40 +90,38 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
90
90
  * @param {C} callback - The `callback` parameter is a function that will be called for each node
91
91
  * that is deleted from the binary tree. It is an optional parameter and if not provided, it will
92
92
  * default to the `_defaultOneParamCallback` function. The `callback` function should have a single
93
- * parameter of type `N
94
- * @returns The method is returning an array of `BinaryTreeDeleteResult<N>`.
93
+ * parameter of type `NODE
94
+ * @returns The method is returning an array of `BinaryTreeDeleteResult<NODE>`.
95
95
  */
96
- delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C): BinaryTreeDeleteResult<N>[];
96
+ delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback?: C): BinaryTreeDeleteResult<NODE>[];
97
97
  /**
98
98
  * The `_swapProperties` function swaps the key, value, and height properties between two nodes in a binary
99
99
  * tree.
100
- * @param {K | N | undefined} srcNode - The `srcNode` parameter represents the source node that
101
- * needs to be swapped with the destination node. It can be of type `K`, `N`, or `undefined`.
102
- * @param {K | N | undefined} destNode - The `destNode` parameter represents the destination
100
+ * @param {K | NODE | undefined} srcNode - The `srcNode` parameter represents the source node that
101
+ * needs to be swapped with the destination node. It can be of type `K`, `NODE`, or `undefined`.
102
+ * @param {K | NODE | undefined} destNode - The `destNode` parameter represents the destination
103
103
  * node where the values from the source node will be swapped to.
104
104
  * @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
105
105
  * if either `srcNode` or `destNode` is undefined.
106
106
  */
107
- protected _swapProperties(srcNode: BSTNKeyOrNode<K, N>, destNode: BSTNKeyOrNode<K, N>): N | undefined;
107
+ protected _swapProperties(srcNode: BSTNKeyOrNode<K, NODE>, destNode: BSTNKeyOrNode<K, NODE>): NODE | undefined;
108
108
  /**
109
109
  * Time Complexity: O(1)
110
110
  * Space Complexity: O(1)
111
- * constant time, as it performs a fixed number of operations. constant space, as it only uses a constant amount of memory.
112
111
  */
113
112
  /**
114
113
  * Time Complexity: O(1)
115
114
  * Space Complexity: O(1)
116
115
  *
117
116
  * The function calculates the balance factor of a node in a binary tree.
118
- * @param {N} node - The parameter "node" represents a node in a binary tree data structure.
117
+ * @param {NODE} node - The parameter "node" represents a node in a binary tree data structure.
119
118
  * @returns the balance factor of a given node. The balance factor is calculated by subtracting the
120
119
  * height of the left subtree from the height of the right subtree.
121
120
  */
122
- protected _balanceFactor(node: N): number;
121
+ protected _balanceFactor(node: NODE): number;
123
122
  /**
124
123
  * Time Complexity: O(1)
125
124
  * Space Complexity: O(1)
126
- * constant time, as it performs a fixed number of operations. constant space, as it only uses a constant amount of memory.
127
125
  */
128
126
  /**
129
127
  * Time Complexity: O(1)
@@ -131,37 +129,33 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
131
129
  *
132
130
  * The function updates the height of a node in a binary tree based on the heights of its left and
133
131
  * right children.
134
- * @param {N} node - The parameter "node" represents a node in a binary tree data structure.
132
+ * @param {NODE} node - The parameter "node" represents a node in a binary tree data structure.
135
133
  */
136
- protected _updateHeight(node: N): void;
134
+ protected _updateHeight(node: NODE): void;
137
135
  /**
138
- * Time Complexity: O(log n)
136
+ * Time Complexity: O(1)
139
137
  * Space Complexity: O(1)
140
- * logarithmic time, where "n" is the number of nodes in the tree. The method traverses the path from the inserted node to the root. constant space, as it doesn't use additional data structures that scale with input size.
141
138
  */
142
139
  /**
143
- * Time Complexity: O(log n)
140
+ * Time Complexity: O(1)
144
141
  * Space Complexity: O(1)
145
142
  *
146
- * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
147
- * to restore balance in an AVL tree after inserting a node.
148
- * @param {N} node - The `node` parameter in the `_balancePath` function represents the node in the
149
- * AVL tree that needs to be balanced.
143
+ * The function `_balanceLL` performs a left-left rotation to balance a binary tree.
144
+ * @param {NODE} A - A is a node in a binary tree.
150
145
  */
151
- protected _balancePath(node: KeyOrNodeOrEntry<K, V, N>): void;
146
+ protected _balanceLL(A: NODE): void;
152
147
  /**
153
148
  * Time Complexity: O(1)
154
149
  * Space Complexity: O(1)
155
- * constant time, as these methods perform a fixed number of operations. constant space, as they only use a constant amount of memory.
156
150
  */
157
151
  /**
158
152
  * Time Complexity: O(1)
159
153
  * Space Complexity: O(1)
160
154
  *
161
- * The function `_balanceLL` performs a left-left rotation to balance a binary tree.
162
- * @param {N} A - A is a node in a binary tree.
155
+ * The `_balanceLR` function performs a left-right rotation to balance a binary tree.
156
+ * @param {NODE} A - A is a node in a binary tree.
163
157
  */
164
- protected _balanceLL(A: N): void;
158
+ protected _balanceLR(A: NODE): void;
165
159
  /**
166
160
  * Time Complexity: O(1)
167
161
  * Space Complexity: O(1)
@@ -170,10 +164,10 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
170
164
  * Time Complexity: O(1)
171
165
  * Space Complexity: O(1)
172
166
  *
173
- * The `_balanceLR` function performs a left-right rotation to balance a binary tree.
174
- * @param {N} A - A is a node in a binary tree.
167
+ * The function `_balanceRR` performs a right-right rotation to balance a binary tree.
168
+ * @param {NODE} A - A is a node in a binary tree.
175
169
  */
176
- protected _balanceLR(A: N): void;
170
+ protected _balanceRR(A: NODE): void;
177
171
  /**
178
172
  * Time Complexity: O(1)
179
173
  * Space Complexity: O(1)
@@ -182,21 +176,24 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
182
176
  * Time Complexity: O(1)
183
177
  * Space Complexity: O(1)
184
178
  *
185
- * The function `_balanceRR` performs a right-right rotation to balance a binary tree.
186
- * @param {N} A - A is a node in a binary tree.
179
+ * The function `_balanceRL` performs a right-left rotation to balance a binary tree.
180
+ * @param {NODE} A - A is a node in a binary tree.
187
181
  */
188
- protected _balanceRR(A: N): void;
182
+ protected _balanceRL(A: NODE): void;
189
183
  /**
190
- * Time Complexity: O(1)
184
+ * Time Complexity: O(log n)
191
185
  * Space Complexity: O(1)
186
+ * logarithmic time, where "n" is the number of nodes in the tree. The method traverses the path from the inserted node to the root. constant space, as it doesn't use additional data structures that scale with input size.
192
187
  */
193
188
  /**
194
- * Time Complexity: O(1)
189
+ * Time Complexity: O(log n)
195
190
  * Space Complexity: O(1)
196
191
  *
197
- * The function `_balanceRL` performs a right-left rotation to balance a binary tree.
198
- * @param {N} A - A is a node in a binary tree.
192
+ * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
193
+ * to restore balance in an AVL tree after inserting a node.
194
+ * @param {NODE} node - The `node` parameter in the `_balancePath` function represents the node in the
195
+ * AVL tree that needs to be balanced.
199
196
  */
200
- protected _balanceRL(A: N): void;
201
- protected _replaceNode(oldNode: N, newNode: N): N;
197
+ protected _balancePath(node: KeyOrNodeOrEntry<K, V, NODE>): void;
198
+ protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
202
199
  }