directed-graph-typed 1.51.8 → 1.52.0

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 (106) hide show
  1. package/dist/data-structures/base/index.d.ts +2 -1
  2. package/dist/data-structures/base/index.js +2 -1
  3. package/dist/data-structures/base/iterable-element-base.d.ts +171 -0
  4. package/dist/data-structures/base/iterable-element-base.js +225 -0
  5. package/dist/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  6. package/dist/data-structures/base/{iterable-base.js → iterable-entry-base.js} +12 -189
  7. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +106 -68
  8. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
  9. package/dist/data-structures/binary-tree/avl-tree.d.ts +82 -62
  10. package/dist/data-structures/binary-tree/avl-tree.js +78 -59
  11. package/dist/data-structures/binary-tree/binary-tree.d.ts +318 -226
  12. package/dist/data-structures/binary-tree/binary-tree.js +475 -363
  13. package/dist/data-structures/binary-tree/bst.d.ts +192 -202
  14. package/dist/data-structures/binary-tree/bst.js +207 -249
  15. package/dist/data-structures/binary-tree/rb-tree.d.ts +73 -74
  16. package/dist/data-structures/binary-tree/rb-tree.js +107 -98
  17. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +92 -75
  18. package/dist/data-structures/binary-tree/tree-multi-map.js +105 -93
  19. package/dist/data-structures/graph/abstract-graph.d.ts +10 -15
  20. package/dist/data-structures/graph/abstract-graph.js +10 -15
  21. package/dist/data-structures/hash/hash-map.d.ts +33 -40
  22. package/dist/data-structures/hash/hash-map.js +40 -55
  23. package/dist/data-structures/heap/heap.d.ts +43 -114
  24. package/dist/data-structures/heap/heap.js +59 -127
  25. package/dist/data-structures/heap/max-heap.d.ts +50 -4
  26. package/dist/data-structures/heap/max-heap.js +76 -10
  27. package/dist/data-structures/heap/min-heap.d.ts +51 -5
  28. package/dist/data-structures/heap/min-heap.js +68 -11
  29. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  30. package/dist/data-structures/linked-list/doubly-linked-list.js +26 -28
  31. package/dist/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  32. package/dist/data-structures/linked-list/singly-linked-list.js +29 -26
  33. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  34. package/dist/data-structures/priority-queue/max-priority-queue.js +79 -10
  35. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  36. package/dist/data-structures/priority-queue/min-priority-queue.js +71 -11
  37. package/dist/data-structures/priority-queue/priority-queue.d.ts +50 -4
  38. package/dist/data-structures/priority-queue/priority-queue.js +70 -1
  39. package/dist/data-structures/queue/deque.d.ts +21 -20
  40. package/dist/data-structures/queue/deque.js +29 -23
  41. package/dist/data-structures/queue/queue.d.ts +8 -28
  42. package/dist/data-structures/queue/queue.js +15 -31
  43. package/dist/data-structures/stack/stack.d.ts +17 -22
  44. package/dist/data-structures/stack/stack.js +25 -24
  45. package/dist/data-structures/trie/trie.d.ts +19 -14
  46. package/dist/data-structures/trie/trie.js +27 -16
  47. package/dist/interfaces/binary-tree.d.ts +7 -7
  48. package/dist/types/common.d.ts +1 -2
  49. package/dist/types/data-structures/base/base.d.ts +5 -2
  50. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -4
  51. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +3 -4
  52. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  53. package/dist/types/data-structures/binary-tree/bst.d.ts +4 -5
  54. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +3 -4
  55. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  56. package/dist/types/data-structures/heap/heap.d.ts +3 -2
  57. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  58. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  59. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  60. package/dist/types/data-structures/queue/deque.d.ts +3 -2
  61. package/dist/types/data-structures/queue/queue.d.ts +2 -1
  62. package/dist/types/data-structures/stack/stack.d.ts +2 -1
  63. package/dist/types/data-structures/trie/trie.d.ts +3 -2
  64. package/dist/utils/utils.js +3 -5
  65. package/package.json +2 -2
  66. package/src/data-structures/base/index.ts +2 -1
  67. package/src/data-structures/base/iterable-element-base.ts +250 -0
  68. package/src/data-structures/base/{iterable-base.ts → iterable-entry-base.ts} +22 -213
  69. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +144 -95
  70. package/src/data-structures/binary-tree/avl-tree.ts +96 -69
  71. package/src/data-structures/binary-tree/binary-tree.ts +535 -403
  72. package/src/data-structures/binary-tree/bst.ts +247 -277
  73. package/src/data-structures/binary-tree/rb-tree.ts +123 -103
  74. package/src/data-structures/binary-tree/tree-multi-map.ts +127 -102
  75. package/src/data-structures/graph/abstract-graph.ts +10 -10
  76. package/src/data-structures/hash/hash-map.ts +46 -53
  77. package/src/data-structures/heap/heap.ts +71 -152
  78. package/src/data-structures/heap/max-heap.ts +88 -13
  79. package/src/data-structures/heap/min-heap.ts +78 -15
  80. package/src/data-structures/linked-list/doubly-linked-list.ts +32 -32
  81. package/src/data-structures/linked-list/singly-linked-list.ts +37 -29
  82. package/src/data-structures/priority-queue/max-priority-queue.ts +94 -13
  83. package/src/data-structures/priority-queue/min-priority-queue.ts +84 -15
  84. package/src/data-structures/priority-queue/priority-queue.ts +81 -4
  85. package/src/data-structures/queue/deque.ts +37 -26
  86. package/src/data-structures/queue/queue.ts +23 -36
  87. package/src/data-structures/stack/stack.ts +31 -26
  88. package/src/data-structures/trie/trie.ts +35 -20
  89. package/src/interfaces/binary-tree.ts +9 -9
  90. package/src/types/common.ts +1 -2
  91. package/src/types/data-structures/base/base.ts +14 -6
  92. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -4
  93. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -4
  94. package/src/types/data-structures/binary-tree/binary-tree.ts +6 -6
  95. package/src/types/data-structures/binary-tree/bst.ts +4 -5
  96. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -4
  97. package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -4
  98. package/src/types/data-structures/heap/heap.ts +4 -1
  99. package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -1
  100. package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -1
  101. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  102. package/src/types/data-structures/queue/deque.ts +3 -1
  103. package/src/types/data-structures/queue/queue.ts +3 -1
  104. package/src/types/data-structures/stack/stack.ts +3 -1
  105. package/src/types/data-structures/trie/trie.ts +3 -1
  106. package/src/utils/utils.ts +3 -3
@@ -1,7 +1,6 @@
1
1
  import type {
2
2
  BinaryTreeDeleteResult,
3
3
  BTNCallback,
4
- Comparable,
5
4
  CRUD,
6
5
  KeyOrNodeOrEntry,
7
6
  RBTNColor,
@@ -9,11 +8,12 @@ import type {
9
8
  RedBlackTreeNested,
10
9
  RedBlackTreeNodeNested
11
10
  } from '../../types';
11
+ import { BTNEntry } from '../../types';
12
12
  import { BST, BSTNode } from './bst';
13
13
  import { IBinaryTree } from '../../interfaces';
14
14
 
15
15
  export class RedBlackTreeNode<
16
- K extends Comparable,
16
+ K = any,
17
17
  V = any,
18
18
  NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>
19
19
  > extends BSTNode<K, V, NODE> {
@@ -53,30 +53,34 @@ export class RedBlackTreeNode<
53
53
  }
54
54
 
55
55
  export class RedBlackTree<
56
- K extends Comparable,
56
+ K = any,
57
57
  V = any,
58
+ R = BTNEntry<K, V>,
58
59
  NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>,
59
- TREE extends RedBlackTree<K, V, NODE, TREE> = RedBlackTree<K, V, NODE, RedBlackTreeNested<K, V, NODE>>
60
+ TREE extends RedBlackTree<K, V, R, NODE, TREE> = RedBlackTree<K, V, R, NODE, RedBlackTreeNested<K, V, R, NODE>>
60
61
  >
61
- extends BST<K, V, NODE, TREE>
62
- implements IBinaryTree<K, V, NODE, TREE> {
62
+ extends BST<K, V, R, NODE, TREE>
63
+ implements IBinaryTree<K, V, R, NODE, TREE> {
63
64
  /**
64
65
  * This is the constructor function for a Red-Black Tree data structure in TypeScript.
65
- * @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
66
- * contain keys, nodes, or entries. It is used to initialize the RBTree with the provided keys,
67
- * nodes, or entries.
66
+ * @param keysOrNodesOrEntriesOrRawElements - The `keysOrNodesOrEntriesOrRawElements` parameter is an
67
+ * iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
68
+ * initialize the RBTree with the provided elements.
68
69
  * @param [options] - The `options` parameter is an optional object that can be passed to the
69
- * constructor. It allows you to customize the behavior of the RBTree. It can include properties such
70
- * as `compareKeys`, `compareValues`, `allowDuplicates`, etc. These properties define how the RBTree
71
- * should compare keys and
70
+ * constructor. It is of type `RBTreeOptions<K, V, R>`. This object can contain various options for
71
+ * configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
72
+ * depend on the implementation
72
73
  */
73
- constructor(keysOrNodesOrEntries: Iterable<KeyOrNodeOrEntry<K, V, NODE>> = [], options?: RBTreeOptions<K>) {
74
+ constructor(
75
+ keysOrNodesOrEntriesOrRawElements: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>> = [],
76
+ options?: RBTreeOptions<K, V, R>
77
+ ) {
74
78
  super([], options);
75
79
 
76
80
  this._root = this.NIL;
77
81
 
78
- if (keysOrNodesOrEntries) {
79
- this.addMany(keysOrNodesOrEntries);
82
+ if (keysOrNodesOrEntriesOrRawElements) {
83
+ this.addMany(keysOrNodesOrEntriesOrRawElements);
80
84
  }
81
85
  }
82
86
 
@@ -92,29 +96,30 @@ export class RedBlackTree<
92
96
 
93
97
  /**
94
98
  * The function creates a new Red-Black Tree node with the specified key, value, and color.
95
- * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
96
- * which is a generic type representing the key's data type.
99
+ * @param {K} key - The key parameter represents the key value of the node being created. It is of
100
+ * type K, which is a generic type that can be replaced with any specific type when using the
101
+ * function.
97
102
  * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
98
- * associated with the key in the node. It is not required and can be omitted if not needed.
99
- * @param {RBTNColor} color - The "color" parameter is used to specify the color of the node in a
100
- * Red-Black Tree. It is an optional parameter with a default value of "'BLACK'". The color
101
- * can be either "'RED'" or "'BLACK'".
102
- * @returns The method is returning a new instance of a RedBlackTreeNode with the specified key,
103
- * value, and color.
103
+ * associated with the key in the node. It is not required and can be omitted if you only need to
104
+ * create a node with a key.
105
+ * @param {RBTNColor} [color=BLACK] - The "color" parameter is used to specify the color of the node
106
+ * in a Red-Black Tree. It can have two possible values: "RED" or "BLACK". By default, the color is
107
+ * set to "BLACK" if not specified.
108
+ * @returns A new instance of a RedBlackTreeNode with the specified key, value, and color is being
109
+ * returned.
104
110
  */
105
111
  override createNode(key: K, value?: V, color: RBTNColor = 'BLACK'): NODE {
106
112
  return new RedBlackTreeNode<K, V, NODE>(key, value, color) as NODE;
107
113
  }
108
114
 
109
115
  /**
110
- * The function creates a Red-Black Tree with the given options and returns it.
111
- * @param [options] - The `options` parameter is an optional object that contains configuration
112
- * options for creating the Red-Black Tree. It is of type `RBTreeOptions<K>`, where `K` represents
113
- * the type of keys in the tree.
116
+ * The function creates a new Red-Black Tree with the specified options.
117
+ * @param [options] - The `options` parameter is an optional object that contains additional
118
+ * configuration options for creating the Red-Black Tree. It has the following properties:
114
119
  * @returns a new instance of a RedBlackTree object.
115
120
  */
116
- override createTree(options?: RBTreeOptions<K>): TREE {
117
- return new RedBlackTree<K, V, NODE, TREE>([], {
121
+ override createTree(options?: RBTreeOptions<K, V, R>): TREE {
122
+ return new RedBlackTree<K, V, R, NODE, TREE>([], {
118
123
  iterationType: this.iterationType,
119
124
  ...options
120
125
  }) as TREE;
@@ -126,54 +131,57 @@ export class RedBlackTree<
126
131
  */
127
132
 
128
133
  /**
129
- * Time Complexity: O(1)
130
- * Space Complexity: O(1)
131
- *
132
- * The function `keyValueOrEntryToNode` takes a key, value, or entry and returns a node if it is
133
- * valid, otherwise it returns undefined.
134
- * @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntry - The key, value, or entry to convert.
135
- * @param {V} [value] - The value associated with the key (if `keyOrNodeOrEntry` is a key).
136
- * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails.
137
- */
138
- override keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined {
139
- let node: NODE | undefined;
140
-
141
- if (keyOrNodeOrEntry === null || keyOrNodeOrEntry === undefined) {
142
- return;
143
- } else if (this.isNode(keyOrNodeOrEntry)) {
144
- node = keyOrNodeOrEntry;
145
- } else if (this.isEntry(keyOrNodeOrEntry)) {
146
- const [key, value] = keyOrNodeOrEntry;
147
- if (key === undefined || key === null) {
148
- return;
149
- } else {
150
- node = this.createNode(key, value, 'RED');
151
- }
152
- } else if (!this.isNode(keyOrNodeOrEntry)) {
153
- node = this.createNode(keyOrNodeOrEntry, value, 'RED');
154
- } else {
155
- return;
156
- }
157
- return node;
158
- }
159
-
160
- /**
161
- * Time Complexity: O(1)
162
- * Space Complexity: O(1)
163
- * /
164
-
165
- /**
166
134
  * Time Complexity: O(1)
167
135
  * Space Complexity: O(1)
168
136
  *
169
137
  * The function checks if the input is an instance of the RedBlackTreeNode class.
170
- * @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntry - The object to check.
171
- * @returns {boolean} - `true` if the object is a Red-Black Tree node, `false` otherwise.
138
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
139
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
140
+ * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
141
+ * an instance of the `RedBlackTreeNode` class.
172
142
  */
173
- override isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE {
174
- return keyOrNodeOrEntry instanceof RedBlackTreeNode;
143
+ override isNode(
144
+ keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>
145
+ ): keyOrNodeOrEntryOrRawElement is NODE {
146
+ return keyOrNodeOrEntryOrRawElement instanceof RedBlackTreeNode;
175
147
  }
176
148
 
149
+ // /**
150
+ // * Time Complexity: O(1)
151
+ // * Space Complexity: O(1)
152
+ // */
153
+ //
154
+ // /**
155
+ // * Time Complexity: O(1)
156
+ // * Space Complexity: O(1)
157
+ // *
158
+ // * The function `keyValueOrEntryOrRawElementToNode` takes a key, value, or entry and returns a node if it is
159
+ // * valid, otherwise it returns undefined.
160
+ // * @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The key, value, or entry to convert.
161
+ // * @param {V} [value] - The value associated with the key (if `keyOrNodeOrEntryOrRawElement` is a key).
162
+ // * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails.
163
+ // */
164
+ // override keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined {
165
+ //
166
+ // if (keyOrNodeOrEntryOrRawElement === null || keyOrNodeOrEntryOrRawElement === undefined) return;
167
+ // if (this.isNode(keyOrNodeOrEntryOrRawElement)) return keyOrNodeOrEntryOrRawElement;
168
+ //
169
+ // if (this.toEntryFn) {
170
+ // const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement as R);
171
+ // if (key) return this.createNode(key, entryValue ?? value, 'RED');
172
+ // }
173
+ //
174
+ // if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
175
+ // const [key, value] = keyOrNodeOrEntryOrRawElement;
176
+ // if (key === undefined || key === null) return;
177
+ // else return this.createNode(key, value, 'RED');
178
+ // }
179
+ //
180
+ // if (this.isKey(keyOrNodeOrEntryOrRawElement)) return this.createNode(keyOrNodeOrEntryOrRawElement, value, 'RED');
181
+ //
182
+ // return ;
183
+ // }
184
+
177
185
  /**
178
186
  * Time Complexity: O(1)
179
187
  * Space Complexity: O(1)
@@ -200,17 +208,19 @@ export class RedBlackTree<
200
208
  * Time Complexity: O(log n)
201
209
  * Space Complexity: O(1)
202
210
  *
203
- * The function adds a new node to a Red-Black Tree data structure and returns a boolean indicating
204
- * whether the operation was successful.
205
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
206
- * entry.
207
- * @param {V} [value] - The `value` parameter is the value associated with the key that is being
208
- * added to the tree.
209
- * @returns The method is returning a boolean value. It returns true if the node was successfully
210
- * added or updated, and false otherwise.
211
+ * The function adds a new node to a binary search tree and returns true if the node was successfully
212
+ * added.
213
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
214
+ * `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
215
+ * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
216
+ * the key in the data structure. It represents the value that you want to add or update in the data
217
+ * structure.
218
+ * @returns The method is returning a boolean value. If a new node is successfully added to the tree,
219
+ * the method returns true. If the node already exists and its value is updated, the method also
220
+ * returns true. If the node cannot be added or updated, the method returns false.
211
221
  */
212
- override add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean {
213
- const newNode = this.keyValueOrEntryToNode(keyOrNodeOrEntry, value);
222
+ override add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean {
223
+ const newNode = this.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value);
214
224
  if (!this.isRealNode(newNode)) return false;
215
225
 
216
226
  const insertStatus = this._insert(newNode);
@@ -236,16 +246,16 @@ export class RedBlackTree<
236
246
  * Time Complexity: O(log n)
237
247
  * Space Complexity: O(1)
238
248
  *
239
- * The function `delete` in a binary tree class deletes a node from the tree and fixes the tree if
240
- * necessary.
241
- * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the
242
- * identifier of the node that needs to be deleted from the binary tree. It can be of any type that
243
- * is returned by the callback function `C`. It can also be `null` or `undefined` if the node to be
244
- * deleted is not found.
245
- * @param {C} callback - The `callback` parameter is a function that is used to retrieve a node from
246
- * the binary tree based on its identifier. It is an optional parameter and if not provided, the
247
- * `_DEFAULT_CALLBACK` function is used as the default callback. The callback function should
248
- * return the identifier of the node to
249
+ * The function overrides the delete method of a binary tree data structure, allowing for the
250
+ * deletion of a node and maintaining the balance of the tree.
251
+ * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the value
252
+ * that identifies the node to be deleted from the binary tree. It can be of any type that is
253
+ * returned by the callback function `C`. It can also be `null` or `undefined` if there is no node to
254
+ * delete.
255
+ * @param {C} callback - The `callback` parameter is a function that is used to determine the
256
+ * equality of nodes in the binary tree. It is optional and has a default value of
257
+ * `this._DEFAULT_CALLBACK`. The type of the `callback` parameter is `C`, which is a generic type
258
+ * that extends the `BTNCallback
249
259
  * @returns an array of BinaryTreeDeleteResult<NODE> objects.
250
260
  */
251
261
  override delete<C extends BTNCallback<NODE>>(
@@ -309,6 +319,14 @@ export class RedBlackTree<
309
319
  }
310
320
 
311
321
  /**
322
+ * Time Complexity: O(1)
323
+ * Space Complexity: O(1)
324
+ */
325
+
326
+ /**
327
+ * Time Complexity: O(1)
328
+ * Space Complexity: O(1)
329
+ *
312
330
  * The function sets the root of a tree-like structure and updates the parent property of the new
313
331
  * root.
314
332
  * @param {NODE | undefined} v - v is a parameter of type NODE or undefined.
@@ -332,8 +350,8 @@ export class RedBlackTree<
332
350
  * The function replaces an old node with a new node while preserving the color of the old node.
333
351
  * @param {NODE} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
334
352
  * the data structure.
335
- * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the old node in
336
- * the data structure.
353
+ * @param {NODE} newNode - The `newNode` parameter is of type `NODE`, which represents a node in a
354
+ * data structure.
337
355
  * @returns The method is returning the result of calling the `_replaceNode` method from the
338
356
  * superclass, with the `oldNode` and `newNode` parameters.
339
357
  */
@@ -352,12 +370,13 @@ export class RedBlackTree<
352
370
  * Time Complexity: O(log n)
353
371
  * Space Complexity: O(1)
354
372
  *
355
- * The `_insert` function inserts or updates a node in a binary search tree and performs necessary
356
- * fix-ups to maintain the red-black tree properties.
357
- * @param {NODE} node - The `node` parameter represents the node that needs to be inserted into a
358
- * binary search tree. It contains a `key` property that is used to determine the position of the
359
- * node in the tree.
360
- * @returns {'inserted' | 'updated'} - The result of the insertion.
373
+ * The `_insert` function inserts a node into a binary search tree and performs necessary fix-ups to
374
+ * maintain the red-black tree properties.
375
+ * @param {NODE} node - The `node` parameter represents the node that needs to be inserted into the
376
+ * binary search tree.
377
+ * @returns a string value indicating the result of the insertion operation. It can return either
378
+ * 'UPDATED' if the node with the same key already exists and was updated, or 'CREATED' if a new node
379
+ * was created and inserted into the tree.
361
380
  */
362
381
  protected _insert(node: NODE): CRUD {
363
382
  let current = this.root;
@@ -432,8 +451,8 @@ export class RedBlackTree<
432
451
  * Space Complexity: O(1)
433
452
  *
434
453
  * The `_insertFixup` function is used to fix the Red-Black Tree after inserting a new node.
435
- * @param {NODE | undefined} z - The parameter `z` represents a node in the Red-Black Tree. It can
436
- * either be a valid node object or `undefined`.
454
+ * @param {NODE | undefined} z - The parameter `z` represents a node in the Red-Black Tree data
455
+ * structure. It can either be a valid node or `undefined`.
437
456
  */
438
457
  protected _insertFixup(z: NODE | undefined): void {
439
458
  // Continue fixing the tree as long as the parent of z is red
@@ -504,9 +523,10 @@ export class RedBlackTree<
504
523
  *
505
524
  * The `_deleteFixup` function is used to fix the red-black tree after a node deletion by adjusting
506
525
  * the colors and performing rotations.
507
- * @param {NODE | undefined} node - The `node` parameter represents a node in a Red-Black Tree data
508
- * structure. It can be either a valid node object or `undefined`.
509
- * @returns The function does not return any value. It has a return type of `void`.
526
+ * @param {NODE | undefined} node - The `node` parameter represents a node in a binary tree. It can
527
+ * be either a valid node object or `undefined`.
528
+ * @returns The function does not return any value. It has a return type of `void`, which means it
529
+ * does not return anything.
510
530
  */
511
531
  protected _deleteFixup(node: NODE | undefined): void {
512
532
  // Early exit condition