data-structure-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 (216) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +13 -13
  3. package/benchmark/report.html +13 -13
  4. package/benchmark/report.json +152 -152
  5. package/dist/cjs/data-structures/base/index.d.ts +2 -1
  6. package/dist/cjs/data-structures/base/index.js +2 -1
  7. package/dist/cjs/data-structures/base/index.js.map +1 -1
  8. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +171 -0
  9. package/dist/cjs/data-structures/base/iterable-element-base.js +226 -0
  10. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -0
  11. package/dist/cjs/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  12. package/dist/cjs/data-structures/base/{iterable-base.js → iterable-entry-base.js} +13 -190
  13. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -0
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +106 -68
  15. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
  16. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +82 -62
  18. package/dist/cjs/data-structures/binary-tree/avl-tree.js +78 -59
  19. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +318 -226
  21. package/dist/cjs/data-structures/binary-tree/binary-tree.js +475 -363
  22. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  23. package/dist/cjs/data-structures/binary-tree/bst.d.ts +192 -202
  24. package/dist/cjs/data-structures/binary-tree/bst.js +207 -249
  25. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  26. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +73 -74
  27. package/dist/cjs/data-structures/binary-tree/rb-tree.js +107 -98
  28. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  29. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +92 -75
  30. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +105 -93
  31. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  32. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +10 -15
  33. package/dist/cjs/data-structures/graph/abstract-graph.js +10 -15
  34. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  35. package/dist/cjs/data-structures/hash/hash-map.d.ts +33 -40
  36. package/dist/cjs/data-structures/hash/hash-map.js +40 -55
  37. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  38. package/dist/cjs/data-structures/heap/heap.d.ts +43 -114
  39. package/dist/cjs/data-structures/heap/heap.js +59 -127
  40. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  41. package/dist/cjs/data-structures/heap/max-heap.d.ts +50 -4
  42. package/dist/cjs/data-structures/heap/max-heap.js +76 -10
  43. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  44. package/dist/cjs/data-structures/heap/min-heap.d.ts +51 -5
  45. package/dist/cjs/data-structures/heap/min-heap.js +68 -11
  46. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  47. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  48. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +26 -28
  49. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  50. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  51. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +29 -26
  52. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  53. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  54. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +79 -10
  55. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  56. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  57. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +71 -11
  58. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  59. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +50 -4
  60. package/dist/cjs/data-structures/priority-queue/priority-queue.js +70 -1
  61. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  62. package/dist/cjs/data-structures/queue/deque.d.ts +21 -20
  63. package/dist/cjs/data-structures/queue/deque.js +29 -23
  64. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  65. package/dist/cjs/data-structures/queue/queue.d.ts +8 -28
  66. package/dist/cjs/data-structures/queue/queue.js +15 -31
  67. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  68. package/dist/cjs/data-structures/stack/stack.d.ts +17 -22
  69. package/dist/cjs/data-structures/stack/stack.js +25 -24
  70. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  71. package/dist/cjs/data-structures/trie/trie.d.ts +19 -14
  72. package/dist/cjs/data-structures/trie/trie.js +27 -16
  73. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  74. package/dist/cjs/interfaces/binary-tree.d.ts +7 -7
  75. package/dist/cjs/types/common.d.ts +1 -2
  76. package/dist/cjs/types/data-structures/base/base.d.ts +5 -2
  77. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -4
  78. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -4
  79. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  80. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +4 -5
  81. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -4
  82. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  83. package/dist/cjs/types/data-structures/heap/heap.d.ts +3 -2
  84. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  85. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  86. package/dist/cjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  87. package/dist/cjs/types/data-structures/queue/deque.d.ts +3 -2
  88. package/dist/cjs/types/data-structures/queue/queue.d.ts +2 -1
  89. package/dist/cjs/types/data-structures/stack/stack.d.ts +2 -1
  90. package/dist/cjs/types/data-structures/trie/trie.d.ts +3 -2
  91. package/dist/cjs/utils/utils.js +3 -5
  92. package/dist/cjs/utils/utils.js.map +1 -1
  93. package/dist/mjs/data-structures/base/index.d.ts +2 -1
  94. package/dist/mjs/data-structures/base/index.js +2 -1
  95. package/dist/mjs/data-structures/base/iterable-element-base.d.ts +171 -0
  96. package/dist/mjs/data-structures/base/iterable-element-base.js +222 -0
  97. package/dist/mjs/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  98. package/dist/mjs/data-structures/base/{iterable-base.js → iterable-entry-base.js} +10 -186
  99. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +106 -68
  100. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
  101. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +82 -62
  102. package/dist/mjs/data-structures/binary-tree/avl-tree.js +78 -59
  103. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +318 -226
  104. package/dist/mjs/data-structures/binary-tree/binary-tree.js +476 -364
  105. package/dist/mjs/data-structures/binary-tree/bst.d.ts +192 -202
  106. package/dist/mjs/data-structures/binary-tree/bst.js +211 -255
  107. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +73 -74
  108. package/dist/mjs/data-structures/binary-tree/rb-tree.js +107 -98
  109. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +92 -75
  110. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +105 -93
  111. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +10 -15
  112. package/dist/mjs/data-structures/graph/abstract-graph.js +10 -15
  113. package/dist/mjs/data-structures/hash/hash-map.d.ts +33 -40
  114. package/dist/mjs/data-structures/hash/hash-map.js +41 -55
  115. package/dist/mjs/data-structures/heap/heap.d.ts +43 -114
  116. package/dist/mjs/data-structures/heap/heap.js +60 -128
  117. package/dist/mjs/data-structures/heap/max-heap.d.ts +50 -4
  118. package/dist/mjs/data-structures/heap/max-heap.js +79 -10
  119. package/dist/mjs/data-structures/heap/min-heap.d.ts +51 -5
  120. package/dist/mjs/data-structures/heap/min-heap.js +68 -11
  121. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  122. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +26 -28
  123. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  124. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +29 -26
  125. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  126. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +82 -10
  127. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  128. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +71 -11
  129. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +50 -4
  130. package/dist/mjs/data-structures/priority-queue/priority-queue.js +70 -1
  131. package/dist/mjs/data-structures/queue/deque.d.ts +21 -20
  132. package/dist/mjs/data-structures/queue/deque.js +29 -23
  133. package/dist/mjs/data-structures/queue/queue.d.ts +8 -28
  134. package/dist/mjs/data-structures/queue/queue.js +15 -31
  135. package/dist/mjs/data-structures/stack/stack.d.ts +17 -22
  136. package/dist/mjs/data-structures/stack/stack.js +25 -24
  137. package/dist/mjs/data-structures/trie/trie.d.ts +19 -14
  138. package/dist/mjs/data-structures/trie/trie.js +27 -16
  139. package/dist/mjs/interfaces/binary-tree.d.ts +7 -7
  140. package/dist/mjs/types/common.d.ts +1 -2
  141. package/dist/mjs/types/data-structures/base/base.d.ts +5 -2
  142. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -4
  143. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -4
  144. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  145. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +4 -5
  146. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -4
  147. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  148. package/dist/mjs/types/data-structures/heap/heap.d.ts +3 -2
  149. package/dist/mjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  150. package/dist/mjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  151. package/dist/mjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  152. package/dist/mjs/types/data-structures/queue/deque.d.ts +3 -2
  153. package/dist/mjs/types/data-structures/queue/queue.d.ts +2 -1
  154. package/dist/mjs/types/data-structures/stack/stack.d.ts +2 -1
  155. package/dist/mjs/types/data-structures/trie/trie.d.ts +3 -2
  156. package/dist/mjs/utils/utils.js +3 -5
  157. package/dist/umd/data-structure-typed.js +1949 -1481
  158. package/dist/umd/data-structure-typed.min.js +2 -2
  159. package/dist/umd/data-structure-typed.min.js.map +1 -1
  160. package/package.json +6 -6
  161. package/src/data-structures/base/index.ts +2 -1
  162. package/src/data-structures/base/iterable-element-base.ts +250 -0
  163. package/src/data-structures/base/{iterable-base.ts → iterable-entry-base.ts} +22 -213
  164. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +144 -95
  165. package/src/data-structures/binary-tree/avl-tree.ts +96 -69
  166. package/src/data-structures/binary-tree/binary-tree.ts +535 -403
  167. package/src/data-structures/binary-tree/bst.ts +247 -277
  168. package/src/data-structures/binary-tree/rb-tree.ts +123 -103
  169. package/src/data-structures/binary-tree/tree-multi-map.ts +127 -102
  170. package/src/data-structures/graph/abstract-graph.ts +10 -10
  171. package/src/data-structures/hash/hash-map.ts +46 -53
  172. package/src/data-structures/heap/heap.ts +71 -152
  173. package/src/data-structures/heap/max-heap.ts +88 -13
  174. package/src/data-structures/heap/min-heap.ts +78 -15
  175. package/src/data-structures/linked-list/doubly-linked-list.ts +32 -32
  176. package/src/data-structures/linked-list/singly-linked-list.ts +37 -29
  177. package/src/data-structures/priority-queue/max-priority-queue.ts +94 -13
  178. package/src/data-structures/priority-queue/min-priority-queue.ts +84 -15
  179. package/src/data-structures/priority-queue/priority-queue.ts +81 -4
  180. package/src/data-structures/queue/deque.ts +37 -26
  181. package/src/data-structures/queue/queue.ts +23 -36
  182. package/src/data-structures/stack/stack.ts +31 -26
  183. package/src/data-structures/trie/trie.ts +35 -20
  184. package/src/interfaces/binary-tree.ts +9 -9
  185. package/src/types/common.ts +1 -2
  186. package/src/types/data-structures/base/base.ts +14 -6
  187. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -4
  188. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -4
  189. package/src/types/data-structures/binary-tree/binary-tree.ts +6 -6
  190. package/src/types/data-structures/binary-tree/bst.ts +4 -5
  191. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -4
  192. package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -4
  193. package/src/types/data-structures/heap/heap.ts +4 -1
  194. package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -1
  195. package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -1
  196. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  197. package/src/types/data-structures/queue/deque.ts +3 -1
  198. package/src/types/data-structures/queue/queue.ts +3 -1
  199. package/src/types/data-structures/stack/stack.ts +3 -1
  200. package/src/types/data-structures/trie/trie.ts +3 -1
  201. package/src/utils/utils.ts +3 -3
  202. package/test/integration/avl-tree.test.ts +2 -2
  203. package/test/integration/bst.test.ts +3 -3
  204. package/test/integration/index.html +25 -11
  205. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +68 -0
  206. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +56 -0
  207. package/test/unit/data-structures/graph/directed-graph.test.ts +2 -2
  208. package/test/unit/data-structures/heap/heap.test.ts +80 -0
  209. package/test/unit/data-structures/heap/max-heap.test.ts +44 -1
  210. package/test/unit/data-structures/heap/min-heap.test.ts +18 -1
  211. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +42 -0
  212. package/test/unit/data-structures/queue/deque.test.ts +30 -0
  213. package/test/unit/data-structures/queue/queue.test.ts +56 -0
  214. package/test/utils/big-o.ts +12 -6
  215. package/tsconfig-base.json +1 -0
  216. package/dist/cjs/data-structures/base/iterable-base.js.map +0 -1
@@ -1,7 +1,8 @@
1
- import type { BinaryTreeDeleteResult, BTNCallback, Comparable, CRUD, KeyOrNodeOrEntry, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
1
+ import type { BinaryTreeDeleteResult, BTNCallback, CRUD, KeyOrNodeOrEntry, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
2
+ import { BTNEntry } from '../../types';
2
3
  import { BST, BSTNode } from './bst';
3
4
  import { IBinaryTree } from '../../interfaces';
4
- export declare class RedBlackTreeNode<K extends Comparable, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
5
+ export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
5
6
  /**
6
7
  * The constructor function initializes a Red-Black Tree Node with a key, an optional value, and a
7
8
  * color.
@@ -26,18 +27,18 @@ export declare class RedBlackTreeNode<K extends Comparable, V = any, NODE extend
26
27
  */
27
28
  set color(value: RBTNColor);
28
29
  }
29
- export declare class RedBlackTree<K extends Comparable, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>, TREE extends RedBlackTree<K, V, NODE, TREE> = RedBlackTree<K, V, NODE, RedBlackTreeNested<K, V, NODE>>> extends BST<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> {
30
+ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>, TREE extends RedBlackTree<K, V, R, NODE, TREE> = RedBlackTree<K, V, R, NODE, RedBlackTreeNested<K, V, R, NODE>>> extends BST<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
30
31
  /**
31
32
  * This is the constructor function for a Red-Black Tree data structure in TypeScript.
32
- * @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
33
- * contain keys, nodes, or entries. It is used to initialize the RBTree with the provided keys,
34
- * nodes, or entries.
33
+ * @param keysOrNodesOrEntriesOrRawElements - The `keysOrNodesOrEntriesOrRawElements` parameter is an
34
+ * iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
35
+ * initialize the RBTree with the provided elements.
35
36
  * @param [options] - The `options` parameter is an optional object that can be passed to the
36
- * constructor. It allows you to customize the behavior of the RBTree. It can include properties such
37
- * as `compareKeys`, `compareValues`, `allowDuplicates`, etc. These properties define how the RBTree
38
- * should compare keys and
37
+ * constructor. It is of type `RBTreeOptions<K, V, R>`. This object can contain various options for
38
+ * configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
39
+ * depend on the implementation
39
40
  */
40
- constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: RBTreeOptions<K>);
41
+ constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, options?: RBTreeOptions<K, V, R>);
41
42
  protected _root: NODE | undefined;
42
43
  /**
43
44
  * The function returns the root node of a tree or undefined if there is no root.
@@ -46,54 +47,41 @@ export declare class RedBlackTree<K extends Comparable, V = any, NODE extends Re
46
47
  get root(): NODE | undefined;
47
48
  /**
48
49
  * The function creates a new Red-Black Tree node with the specified key, value, and color.
49
- * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
50
- * which is a generic type representing the key's data type.
50
+ * @param {K} key - The key parameter represents the key value of the node being created. It is of
51
+ * type K, which is a generic type that can be replaced with any specific type when using the
52
+ * function.
51
53
  * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
52
- * associated with the key in the node. It is not required and can be omitted if not needed.
53
- * @param {RBTNColor} color - The "color" parameter is used to specify the color of the node in a
54
- * Red-Black Tree. It is an optional parameter with a default value of "'BLACK'". The color
55
- * can be either "'RED'" or "'BLACK'".
56
- * @returns The method is returning a new instance of a RedBlackTreeNode with the specified key,
57
- * value, and color.
54
+ * associated with the key in the node. It is not required and can be omitted if you only need to
55
+ * create a node with a key.
56
+ * @param {RBTNColor} [color=BLACK] - The "color" parameter is used to specify the color of the node
57
+ * in a Red-Black Tree. It can have two possible values: "RED" or "BLACK". By default, the color is
58
+ * set to "BLACK" if not specified.
59
+ * @returns A new instance of a RedBlackTreeNode with the specified key, value, and color is being
60
+ * returned.
58
61
  */
59
62
  createNode(key: K, value?: V, color?: RBTNColor): NODE;
60
63
  /**
61
- * The function creates a Red-Black Tree with the given options and returns it.
62
- * @param [options] - The `options` parameter is an optional object that contains configuration
63
- * options for creating the Red-Black Tree. It is of type `RBTreeOptions<K>`, where `K` represents
64
- * the type of keys in the tree.
64
+ * The function creates a new Red-Black Tree with the specified options.
65
+ * @param [options] - The `options` parameter is an optional object that contains additional
66
+ * configuration options for creating the Red-Black Tree. It has the following properties:
65
67
  * @returns a new instance of a RedBlackTree object.
66
68
  */
67
- createTree(options?: RBTreeOptions<K>): TREE;
69
+ createTree(options?: RBTreeOptions<K, V, R>): TREE;
68
70
  /**
69
71
  * Time Complexity: O(1)
70
72
  * Space Complexity: O(1)
71
73
  */
72
74
  /**
73
- * Time Complexity: O(1)
74
- * Space Complexity: O(1)
75
- *
76
- * The function `keyValueOrEntryToNode` takes a key, value, or entry and returns a node if it is
77
- * valid, otherwise it returns undefined.
78
- * @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntry - The key, value, or entry to convert.
79
- * @param {V} [value] - The value associated with the key (if `keyOrNodeOrEntry` is a key).
80
- * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails.
81
- */
82
- keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined;
83
- /**
84
- * Time Complexity: O(1)
85
- * Space Complexity: O(1)
86
- * /
87
-
88
- /**
89
75
  * Time Complexity: O(1)
90
76
  * Space Complexity: O(1)
91
77
  *
92
78
  * The function checks if the input is an instance of the RedBlackTreeNode class.
93
- * @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntry - The object to check.
94
- * @returns {boolean} - `true` if the object is a Red-Black Tree node, `false` otherwise.
79
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
80
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
81
+ * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
82
+ * an instance of the `RedBlackTreeNode` class.
95
83
  */
96
- isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE;
84
+ isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
97
85
  /**
98
86
  * Time Complexity: O(1)
99
87
  * Space Complexity: O(1)
@@ -114,16 +102,18 @@ export declare class RedBlackTree<K extends Comparable, V = any, NODE extends Re
114
102
  * Time Complexity: O(log n)
115
103
  * Space Complexity: O(1)
116
104
  *
117
- * The function adds a new node to a Red-Black Tree data structure and returns a boolean indicating
118
- * whether the operation was successful.
119
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
120
- * entry.
121
- * @param {V} [value] - The `value` parameter is the value associated with the key that is being
122
- * added to the tree.
123
- * @returns The method is returning a boolean value. It returns true if the node was successfully
124
- * added or updated, and false otherwise.
105
+ * The function adds a new node to a binary search tree and returns true if the node was successfully
106
+ * added.
107
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
108
+ * `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
109
+ * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
110
+ * the key in the data structure. It represents the value that you want to add or update in the data
111
+ * structure.
112
+ * @returns The method is returning a boolean value. If a new node is successfully added to the tree,
113
+ * the method returns true. If the node already exists and its value is updated, the method also
114
+ * returns true. If the node cannot be added or updated, the method returns false.
125
115
  */
126
- add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
116
+ add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
127
117
  /**
128
118
  * Time Complexity: O(log n)
129
119
  * Space Complexity: O(1)
@@ -132,20 +122,27 @@ export declare class RedBlackTree<K extends Comparable, V = any, NODE extends Re
132
122
  * Time Complexity: O(log n)
133
123
  * Space Complexity: O(1)
134
124
  *
135
- * The function `delete` in a binary tree class deletes a node from the tree and fixes the tree if
136
- * necessary.
137
- * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the
138
- * identifier of the node that needs to be deleted from the binary tree. It can be of any type that
139
- * is returned by the callback function `C`. It can also be `null` or `undefined` if the node to be
140
- * deleted is not found.
141
- * @param {C} callback - The `callback` parameter is a function that is used to retrieve a node from
142
- * the binary tree based on its identifier. It is an optional parameter and if not provided, the
143
- * `_DEFAULT_CALLBACK` function is used as the default callback. The callback function should
144
- * return the identifier of the node to
125
+ * The function overrides the delete method of a binary tree data structure, allowing for the
126
+ * deletion of a node and maintaining the balance of the tree.
127
+ * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the value
128
+ * that identifies the node to be deleted from the binary tree. It can be of any type that is
129
+ * returned by the callback function `C`. It can also be `null` or `undefined` if there is no node to
130
+ * delete.
131
+ * @param {C} callback - The `callback` parameter is a function that is used to determine the
132
+ * equality of nodes in the binary tree. It is optional and has a default value of
133
+ * `this._DEFAULT_CALLBACK`. The type of the `callback` parameter is `C`, which is a generic type
134
+ * that extends the `BTNCallback
145
135
  * @returns an array of BinaryTreeDeleteResult<NODE> objects.
146
136
  */
147
137
  delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback?: C): BinaryTreeDeleteResult<NODE>[];
148
138
  /**
139
+ * Time Complexity: O(1)
140
+ * Space Complexity: O(1)
141
+ */
142
+ /**
143
+ * Time Complexity: O(1)
144
+ * Space Complexity: O(1)
145
+ *
149
146
  * The function sets the root of a tree-like structure and updates the parent property of the new
150
147
  * root.
151
148
  * @param {NODE | undefined} v - v is a parameter of type NODE or undefined.
@@ -162,8 +159,8 @@ export declare class RedBlackTree<K extends Comparable, V = any, NODE extends Re
162
159
  * The function replaces an old node with a new node while preserving the color of the old node.
163
160
  * @param {NODE} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
164
161
  * the data structure.
165
- * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the old node in
166
- * the data structure.
162
+ * @param {NODE} newNode - The `newNode` parameter is of type `NODE`, which represents a node in a
163
+ * data structure.
167
164
  * @returns The method is returning the result of calling the `_replaceNode` method from the
168
165
  * superclass, with the `oldNode` and `newNode` parameters.
169
166
  */
@@ -176,12 +173,13 @@ export declare class RedBlackTree<K extends Comparable, V = any, NODE extends Re
176
173
  * Time Complexity: O(log n)
177
174
  * Space Complexity: O(1)
178
175
  *
179
- * The `_insert` function inserts or updates a node in a binary search tree and performs necessary
180
- * fix-ups to maintain the red-black tree properties.
181
- * @param {NODE} node - The `node` parameter represents the node that needs to be inserted into a
182
- * binary search tree. It contains a `key` property that is used to determine the position of the
183
- * node in the tree.
184
- * @returns {'inserted' | 'updated'} - The result of the insertion.
176
+ * The `_insert` function inserts a node into a binary search tree and performs necessary fix-ups to
177
+ * maintain the red-black tree properties.
178
+ * @param {NODE} node - The `node` parameter represents the node that needs to be inserted into the
179
+ * binary search tree.
180
+ * @returns a string value indicating the result of the insertion operation. It can return either
181
+ * 'UPDATED' if the node with the same key already exists and was updated, or 'CREATED' if a new node
182
+ * was created and inserted into the tree.
185
183
  */
186
184
  protected _insert(node: NODE): CRUD;
187
185
  /**
@@ -207,8 +205,8 @@ export declare class RedBlackTree<K extends Comparable, V = any, NODE extends Re
207
205
  * Space Complexity: O(1)
208
206
  *
209
207
  * The `_insertFixup` function is used to fix the Red-Black Tree after inserting a new node.
210
- * @param {NODE | undefined} z - The parameter `z` represents a node in the Red-Black Tree. It can
211
- * either be a valid node object or `undefined`.
208
+ * @param {NODE | undefined} z - The parameter `z` represents a node in the Red-Black Tree data
209
+ * structure. It can either be a valid node or `undefined`.
212
210
  */
213
211
  protected _insertFixup(z: NODE | undefined): void;
214
212
  /**
@@ -221,9 +219,10 @@ export declare class RedBlackTree<K extends Comparable, V = any, NODE extends Re
221
219
  *
222
220
  * The `_deleteFixup` function is used to fix the red-black tree after a node deletion by adjusting
223
221
  * the colors and performing rotations.
224
- * @param {NODE | undefined} node - The `node` parameter represents a node in a Red-Black Tree data
225
- * structure. It can be either a valid node object or `undefined`.
226
- * @returns The function does not return any value. It has a return type of `void`.
222
+ * @param {NODE | undefined} node - The `node` parameter represents a node in a binary tree. It can
223
+ * be either a valid node object or `undefined`.
224
+ * @returns The function does not return any value. It has a return type of `void`, which means it
225
+ * does not return anything.
227
226
  */
228
227
  protected _deleteFixup(node: NODE | undefined): void;
229
228
  /**
@@ -34,19 +34,19 @@ export class RedBlackTreeNode extends BSTNode {
34
34
  export class RedBlackTree extends BST {
35
35
  /**
36
36
  * This is the constructor function for a Red-Black Tree data structure in TypeScript.
37
- * @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
38
- * contain keys, nodes, or entries. It is used to initialize the RBTree with the provided keys,
39
- * nodes, or entries.
37
+ * @param keysOrNodesOrEntriesOrRawElements - The `keysOrNodesOrEntriesOrRawElements` parameter is an
38
+ * iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
39
+ * initialize the RBTree with the provided elements.
40
40
  * @param [options] - The `options` parameter is an optional object that can be passed to the
41
- * constructor. It allows you to customize the behavior of the RBTree. It can include properties such
42
- * as `compareKeys`, `compareValues`, `allowDuplicates`, etc. These properties define how the RBTree
43
- * should compare keys and
41
+ * constructor. It is of type `RBTreeOptions<K, V, R>`. This object can contain various options for
42
+ * configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
43
+ * depend on the implementation
44
44
  */
45
- constructor(keysOrNodesOrEntries = [], options) {
45
+ constructor(keysOrNodesOrEntriesOrRawElements = [], options) {
46
46
  super([], options);
47
47
  this._root = this.NIL;
48
- if (keysOrNodesOrEntries) {
49
- this.addMany(keysOrNodesOrEntries);
48
+ if (keysOrNodesOrEntriesOrRawElements) {
49
+ this.addMany(keysOrNodesOrEntriesOrRawElements);
50
50
  }
51
51
  }
52
52
  _root;
@@ -59,24 +59,25 @@ export class RedBlackTree extends BST {
59
59
  }
60
60
  /**
61
61
  * The function creates a new Red-Black Tree node with the specified key, value, and color.
62
- * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
63
- * which is a generic type representing the key's data type.
62
+ * @param {K} key - The key parameter represents the key value of the node being created. It is of
63
+ * type K, which is a generic type that can be replaced with any specific type when using the
64
+ * function.
64
65
  * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
65
- * associated with the key in the node. It is not required and can be omitted if not needed.
66
- * @param {RBTNColor} color - The "color" parameter is used to specify the color of the node in a
67
- * Red-Black Tree. It is an optional parameter with a default value of "'BLACK'". The color
68
- * can be either "'RED'" or "'BLACK'".
69
- * @returns The method is returning a new instance of a RedBlackTreeNode with the specified key,
70
- * value, and color.
66
+ * associated with the key in the node. It is not required and can be omitted if you only need to
67
+ * create a node with a key.
68
+ * @param {RBTNColor} [color=BLACK] - The "color" parameter is used to specify the color of the node
69
+ * in a Red-Black Tree. It can have two possible values: "RED" or "BLACK". By default, the color is
70
+ * set to "BLACK" if not specified.
71
+ * @returns A new instance of a RedBlackTreeNode with the specified key, value, and color is being
72
+ * returned.
71
73
  */
72
74
  createNode(key, value, color = 'BLACK') {
73
75
  return new RedBlackTreeNode(key, value, color);
74
76
  }
75
77
  /**
76
- * The function creates a Red-Black Tree with the given options and returns it.
77
- * @param [options] - The `options` parameter is an optional object that contains configuration
78
- * options for creating the Red-Black Tree. It is of type `RBTreeOptions<K>`, where `K` represents
79
- * the type of keys in the tree.
78
+ * The function creates a new Red-Black Tree with the specified options.
79
+ * @param [options] - The `options` parameter is an optional object that contains additional
80
+ * configuration options for creating the Red-Black Tree. It has the following properties:
80
81
  * @returns a new instance of a RedBlackTree object.
81
82
  */
82
83
  createTree(options) {
@@ -90,56 +91,53 @@ export class RedBlackTree extends BST {
90
91
  * Space Complexity: O(1)
91
92
  */
92
93
  /**
93
- * Time Complexity: O(1)
94
- * Space Complexity: O(1)
95
- *
96
- * The function `keyValueOrEntryToNode` takes a key, value, or entry and returns a node if it is
97
- * valid, otherwise it returns undefined.
98
- * @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntry - The key, value, or entry to convert.
99
- * @param {V} [value] - The value associated with the key (if `keyOrNodeOrEntry` is a key).
100
- * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails.
101
- */
102
- keyValueOrEntryToNode(keyOrNodeOrEntry, value) {
103
- let node;
104
- if (keyOrNodeOrEntry === null || keyOrNodeOrEntry === undefined) {
105
- return;
106
- }
107
- else if (this.isNode(keyOrNodeOrEntry)) {
108
- node = keyOrNodeOrEntry;
109
- }
110
- else if (this.isEntry(keyOrNodeOrEntry)) {
111
- const [key, value] = keyOrNodeOrEntry;
112
- if (key === undefined || key === null) {
113
- return;
114
- }
115
- else {
116
- node = this.createNode(key, value, 'RED');
117
- }
118
- }
119
- else if (!this.isNode(keyOrNodeOrEntry)) {
120
- node = this.createNode(keyOrNodeOrEntry, value, 'RED');
121
- }
122
- else {
123
- return;
124
- }
125
- return node;
126
- }
127
- /**
128
- * Time Complexity: O(1)
129
- * Space Complexity: O(1)
130
- * /
131
-
132
- /**
133
94
  * Time Complexity: O(1)
134
95
  * Space Complexity: O(1)
135
96
  *
136
97
  * The function checks if the input is an instance of the RedBlackTreeNode class.
137
- * @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntry - The object to check.
138
- * @returns {boolean} - `true` if the object is a Red-Black Tree node, `false` otherwise.
98
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
99
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
100
+ * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
101
+ * an instance of the `RedBlackTreeNode` class.
139
102
  */
140
- isNode(keyOrNodeOrEntry) {
141
- return keyOrNodeOrEntry instanceof RedBlackTreeNode;
103
+ isNode(keyOrNodeOrEntryOrRawElement) {
104
+ return keyOrNodeOrEntryOrRawElement instanceof RedBlackTreeNode;
142
105
  }
106
+ // /**
107
+ // * Time Complexity: O(1)
108
+ // * Space Complexity: O(1)
109
+ // */
110
+ //
111
+ // /**
112
+ // * Time Complexity: O(1)
113
+ // * Space Complexity: O(1)
114
+ // *
115
+ // * The function `keyValueOrEntryOrRawElementToNode` takes a key, value, or entry and returns a node if it is
116
+ // * valid, otherwise it returns undefined.
117
+ // * @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The key, value, or entry to convert.
118
+ // * @param {V} [value] - The value associated with the key (if `keyOrNodeOrEntryOrRawElement` is a key).
119
+ // * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails.
120
+ // */
121
+ // override keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined {
122
+ //
123
+ // if (keyOrNodeOrEntryOrRawElement === null || keyOrNodeOrEntryOrRawElement === undefined) return;
124
+ // if (this.isNode(keyOrNodeOrEntryOrRawElement)) return keyOrNodeOrEntryOrRawElement;
125
+ //
126
+ // if (this.toEntryFn) {
127
+ // const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement as R);
128
+ // if (key) return this.createNode(key, entryValue ?? value, 'RED');
129
+ // }
130
+ //
131
+ // if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
132
+ // const [key, value] = keyOrNodeOrEntryOrRawElement;
133
+ // if (key === undefined || key === null) return;
134
+ // else return this.createNode(key, value, 'RED');
135
+ // }
136
+ //
137
+ // if (this.isKey(keyOrNodeOrEntryOrRawElement)) return this.createNode(keyOrNodeOrEntryOrRawElement, value, 'RED');
138
+ //
139
+ // return ;
140
+ // }
143
141
  /**
144
142
  * Time Complexity: O(1)
145
143
  * Space Complexity: O(1)
@@ -163,17 +161,19 @@ export class RedBlackTree extends BST {
163
161
  * Time Complexity: O(log n)
164
162
  * Space Complexity: O(1)
165
163
  *
166
- * The function adds a new node to a Red-Black Tree data structure and returns a boolean indicating
167
- * whether the operation was successful.
168
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
169
- * entry.
170
- * @param {V} [value] - The `value` parameter is the value associated with the key that is being
171
- * added to the tree.
172
- * @returns The method is returning a boolean value. It returns true if the node was successfully
173
- * added or updated, and false otherwise.
164
+ * The function adds a new node to a binary search tree and returns true if the node was successfully
165
+ * added.
166
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
167
+ * `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
168
+ * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
169
+ * the key in the data structure. It represents the value that you want to add or update in the data
170
+ * structure.
171
+ * @returns The method is returning a boolean value. If a new node is successfully added to the tree,
172
+ * the method returns true. If the node already exists and its value is updated, the method also
173
+ * returns true. If the node cannot be added or updated, the method returns false.
174
174
  */
175
- add(keyOrNodeOrEntry, value) {
176
- const newNode = this.keyValueOrEntryToNode(keyOrNodeOrEntry, value);
175
+ add(keyOrNodeOrEntryOrRawElement, value) {
176
+ const newNode = this.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value);
177
177
  if (!this.isRealNode(newNode))
178
178
  return false;
179
179
  const insertStatus = this._insert(newNode);
@@ -199,16 +199,16 @@ export class RedBlackTree extends BST {
199
199
  * Time Complexity: O(log n)
200
200
  * Space Complexity: O(1)
201
201
  *
202
- * The function `delete` in a binary tree class deletes a node from the tree and fixes the tree if
203
- * necessary.
204
- * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the
205
- * identifier of the node that needs to be deleted from the binary tree. It can be of any type that
206
- * is returned by the callback function `C`. It can also be `null` or `undefined` if the node to be
207
- * deleted is not found.
208
- * @param {C} callback - The `callback` parameter is a function that is used to retrieve a node from
209
- * the binary tree based on its identifier. It is an optional parameter and if not provided, the
210
- * `_DEFAULT_CALLBACK` function is used as the default callback. The callback function should
211
- * return the identifier of the node to
202
+ * The function overrides the delete method of a binary tree data structure, allowing for the
203
+ * deletion of a node and maintaining the balance of the tree.
204
+ * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the value
205
+ * that identifies the node to be deleted from the binary tree. It can be of any type that is
206
+ * returned by the callback function `C`. It can also be `null` or `undefined` if there is no node to
207
+ * delete.
208
+ * @param {C} callback - The `callback` parameter is a function that is used to determine the
209
+ * equality of nodes in the binary tree. It is optional and has a default value of
210
+ * `this._DEFAULT_CALLBACK`. The type of the `callback` parameter is `C`, which is a generic type
211
+ * that extends the `BTNCallback
212
212
  * @returns an array of BinaryTreeDeleteResult<NODE> objects.
213
213
  */
214
214
  delete(identifier, callback = this._DEFAULT_CALLBACK) {
@@ -264,6 +264,13 @@ export class RedBlackTree extends BST {
264
264
  return results;
265
265
  }
266
266
  /**
267
+ * Time Complexity: O(1)
268
+ * Space Complexity: O(1)
269
+ */
270
+ /**
271
+ * Time Complexity: O(1)
272
+ * Space Complexity: O(1)
273
+ *
267
274
  * The function sets the root of a tree-like structure and updates the parent property of the new
268
275
  * root.
269
276
  * @param {NODE | undefined} v - v is a parameter of type NODE or undefined.
@@ -285,8 +292,8 @@ export class RedBlackTree extends BST {
285
292
  * The function replaces an old node with a new node while preserving the color of the old node.
286
293
  * @param {NODE} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
287
294
  * the data structure.
288
- * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the old node in
289
- * the data structure.
295
+ * @param {NODE} newNode - The `newNode` parameter is of type `NODE`, which represents a node in a
296
+ * data structure.
290
297
  * @returns The method is returning the result of calling the `_replaceNode` method from the
291
298
  * superclass, with the `oldNode` and `newNode` parameters.
292
299
  */
@@ -302,12 +309,13 @@ export class RedBlackTree extends BST {
302
309
  * Time Complexity: O(log n)
303
310
  * Space Complexity: O(1)
304
311
  *
305
- * The `_insert` function inserts or updates a node in a binary search tree and performs necessary
306
- * fix-ups to maintain the red-black tree properties.
307
- * @param {NODE} node - The `node` parameter represents the node that needs to be inserted into a
308
- * binary search tree. It contains a `key` property that is used to determine the position of the
309
- * node in the tree.
310
- * @returns {'inserted' | 'updated'} - The result of the insertion.
312
+ * The `_insert` function inserts a node into a binary search tree and performs necessary fix-ups to
313
+ * maintain the red-black tree properties.
314
+ * @param {NODE} node - The `node` parameter represents the node that needs to be inserted into the
315
+ * binary search tree.
316
+ * @returns a string value indicating the result of the insertion operation. It can return either
317
+ * 'UPDATED' if the node with the same key already exists and was updated, or 'CREATED' if a new node
318
+ * was created and inserted into the tree.
311
319
  */
312
320
  _insert(node) {
313
321
  let current = this.root;
@@ -378,8 +386,8 @@ export class RedBlackTree extends BST {
378
386
  * Space Complexity: O(1)
379
387
  *
380
388
  * The `_insertFixup` function is used to fix the Red-Black Tree after inserting a new node.
381
- * @param {NODE | undefined} z - The parameter `z` represents a node in the Red-Black Tree. It can
382
- * either be a valid node object or `undefined`.
389
+ * @param {NODE | undefined} z - The parameter `z` represents a node in the Red-Black Tree data
390
+ * structure. It can either be a valid node or `undefined`.
383
391
  */
384
392
  _insertFixup(z) {
385
393
  // Continue fixing the tree as long as the parent of z is red
@@ -449,9 +457,10 @@ export class RedBlackTree extends BST {
449
457
  *
450
458
  * The `_deleteFixup` function is used to fix the red-black tree after a node deletion by adjusting
451
459
  * the colors and performing rotations.
452
- * @param {NODE | undefined} node - The `node` parameter represents a node in a Red-Black Tree data
453
- * structure. It can be either a valid node object or `undefined`.
454
- * @returns The function does not return any value. It has a return type of `void`.
460
+ * @param {NODE | undefined} node - The `node` parameter represents a node in a binary tree. It can
461
+ * be either a valid node object or `undefined`.
462
+ * @returns The function does not return any value. It has a return type of `void`, which means it
463
+ * does not return anything.
455
464
  */
456
465
  _deleteFixup(node) {
457
466
  // Early exit condition