bst-typed 1.54.2 → 2.0.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 (85) hide show
  1. package/README.md +3 -3
  2. package/dist/data-structures/base/iterable-element-base.d.ts +14 -40
  3. package/dist/data-structures/base/iterable-element-base.js +14 -11
  4. package/dist/data-structures/base/linear-base.d.ts +277 -0
  5. package/dist/data-structures/base/linear-base.js +552 -0
  6. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +21 -20
  7. package/dist/data-structures/binary-tree/avl-tree-counter.js +8 -7
  8. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +23 -19
  9. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +51 -38
  10. package/dist/data-structures/binary-tree/avl-tree.d.ts +89 -21
  11. package/dist/data-structures/binary-tree/avl-tree.js +76 -8
  12. package/dist/data-structures/binary-tree/binary-tree.d.ts +173 -225
  13. package/dist/data-structures/binary-tree/binary-tree.js +244 -149
  14. package/dist/data-structures/binary-tree/bst.d.ts +62 -56
  15. package/dist/data-structures/binary-tree/bst.js +89 -133
  16. package/dist/data-structures/binary-tree/red-black-tree.d.ts +19 -25
  17. package/dist/data-structures/binary-tree/red-black-tree.js +7 -13
  18. package/dist/data-structures/binary-tree/tree-counter.d.ts +19 -19
  19. package/dist/data-structures/binary-tree/tree-counter.js +12 -12
  20. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +186 -25
  21. package/dist/data-structures/binary-tree/tree-multi-map.js +211 -41
  22. package/dist/data-structures/graph/abstract-graph.js +2 -2
  23. package/dist/data-structures/heap/heap.d.ts +3 -11
  24. package/dist/data-structures/heap/heap.js +0 -10
  25. package/dist/data-structures/heap/max-heap.d.ts +2 -2
  26. package/dist/data-structures/heap/min-heap.d.ts +2 -2
  27. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +65 -94
  28. package/dist/data-structures/linked-list/doubly-linked-list.js +131 -146
  29. package/dist/data-structures/linked-list/singly-linked-list.d.ts +79 -75
  30. package/dist/data-structures/linked-list/singly-linked-list.js +217 -169
  31. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
  32. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
  33. package/dist/data-structures/priority-queue/priority-queue.d.ts +2 -2
  34. package/dist/data-structures/queue/deque.d.ts +130 -91
  35. package/dist/data-structures/queue/deque.js +269 -169
  36. package/dist/data-structures/queue/queue.d.ts +84 -40
  37. package/dist/data-structures/queue/queue.js +134 -50
  38. package/dist/data-structures/stack/stack.d.ts +3 -11
  39. package/dist/data-structures/stack/stack.js +0 -10
  40. package/dist/data-structures/trie/trie.d.ts +4 -3
  41. package/dist/data-structures/trie/trie.js +3 -0
  42. package/dist/types/data-structures/base/base.d.ts +9 -4
  43. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
  44. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -0
  45. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
  46. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
  47. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
  48. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +2 -2
  49. package/dist/types/data-structures/queue/deque.d.ts +2 -3
  50. package/dist/types/data-structures/queue/queue.d.ts +2 -2
  51. package/dist/utils/utils.d.ts +2 -2
  52. package/package.json +2 -2
  53. package/src/data-structures/base/iterable-element-base.ts +29 -20
  54. package/src/data-structures/base/linear-base.ts +649 -0
  55. package/src/data-structures/binary-tree/avl-tree-counter.ts +30 -23
  56. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +74 -49
  57. package/src/data-structures/binary-tree/avl-tree.ts +99 -29
  58. package/src/data-structures/binary-tree/binary-tree.ts +474 -257
  59. package/src/data-structures/binary-tree/bst.ts +150 -152
  60. package/src/data-structures/binary-tree/red-black-tree.ts +27 -35
  61. package/src/data-structures/binary-tree/tree-counter.ts +33 -27
  62. package/src/data-structures/binary-tree/tree-multi-map.ts +235 -53
  63. package/src/data-structures/graph/abstract-graph.ts +2 -2
  64. package/src/data-structures/heap/heap.ts +3 -14
  65. package/src/data-structures/heap/max-heap.ts +2 -2
  66. package/src/data-structures/heap/min-heap.ts +2 -2
  67. package/src/data-structures/linked-list/doubly-linked-list.ts +144 -160
  68. package/src/data-structures/linked-list/singly-linked-list.ts +241 -185
  69. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -5
  70. package/src/data-structures/priority-queue/min-priority-queue.ts +2 -5
  71. package/src/data-structures/priority-queue/priority-queue.ts +2 -2
  72. package/src/data-structures/queue/deque.ts +286 -183
  73. package/src/data-structures/queue/queue.ts +149 -63
  74. package/src/data-structures/stack/stack.ts +3 -18
  75. package/src/data-structures/trie/trie.ts +7 -3
  76. package/src/types/data-structures/base/base.ts +17 -8
  77. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
  78. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -0
  79. package/src/types/data-structures/binary-tree/bst.ts +1 -1
  80. package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -1
  81. package/src/types/data-structures/linked-list/doubly-linked-list.ts +2 -2
  82. package/src/types/data-structures/linked-list/singly-linked-list.ts +2 -2
  83. package/src/types/data-structures/queue/deque.ts +2 -3
  84. package/src/types/data-structures/queue/queue.ts +2 -2
  85. package/src/utils/utils.ts +2 -2
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BinaryTreeDeleteResult, BinaryTreeOptions, BinaryTreePrintOptions, BTNEntry, BTNRep, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodeDisplayLayout, NodePredicate, OptNodeOrNull, RBTNColor, ToEntryFn } from '../../types';
8
+ import type { BinaryTreeDeleteResult, BinaryTreeOptions, BinaryTreePrintOptions, BTNEntry, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodeDisplayLayout, NodePredicate, OptNodeOrNull, RBTNColor, ToEntryFn } from '../../types';
9
9
  import { IBinaryTree } from '../../interfaces';
10
10
  import { IterableEntryBase } from '../base';
11
11
  import { Range } from '../../common';
@@ -15,6 +15,9 @@ import { Range } from '../../common';
15
15
  * @template BinaryTreeNode<K, V> - The type of the family relationship in the binary tree.
16
16
  */
17
17
  export declare class BinaryTreeNode<K = any, V = any> {
18
+ key: K;
19
+ value?: V;
20
+ parent?: BinaryTreeNode<K, V>;
18
21
  /**
19
22
  * The constructor function initializes an object with a key and an optional value in TypeScript.
20
23
  * @param {K} key - The `key` parameter in the constructor function is used to store the key value
@@ -24,15 +27,12 @@ export declare class BinaryTreeNode<K = any, V = any> {
24
27
  * default to `undefined`.
25
28
  */
26
29
  constructor(key: K, value?: V);
27
- key: K;
28
- value?: V;
29
- parent?: BinaryTreeNode<K, V>;
30
- _left?: OptNodeOrNull<BinaryTreeNode<K, V>>;
31
- get left(): OptNodeOrNull<BinaryTreeNode<K, V>>;
32
- set left(v: OptNodeOrNull<BinaryTreeNode<K, V>>);
33
- _right?: OptNodeOrNull<BinaryTreeNode<K, V>>;
34
- get right(): OptNodeOrNull<BinaryTreeNode<K, V>>;
35
- set right(v: OptNodeOrNull<BinaryTreeNode<K, V>>);
30
+ _left?: BinaryTreeNode<K, V> | null | undefined;
31
+ get left(): BinaryTreeNode<K, V> | null | undefined;
32
+ set left(v: BinaryTreeNode<K, V> | null | undefined);
33
+ _right?: BinaryTreeNode<K, V> | null | undefined;
34
+ get right(): BinaryTreeNode<K, V> | null | undefined;
35
+ set right(v: BinaryTreeNode<K, V> | null | undefined);
36
36
  _height: number;
37
37
  get height(): number;
38
38
  set height(value: number);
@@ -50,25 +50,89 @@ export declare class BinaryTreeNode<K = any, V = any> {
50
50
  * 3. Depth and Height: Depth is the number of edges from the root to a node; height is the maximum depth in the tree.
51
51
  * 4. Subtrees: Each child of a node forms the root of a subtree.
52
52
  * 5. Leaf Nodes: Nodes without children are leaves.
53
+ * @example
54
+ * // determine loan approval using a decision tree
55
+ * // Decision tree structure
56
+ * const loanDecisionTree = new BinaryTree<string>(
57
+ * ['stableIncome', 'goodCredit', 'Rejected', 'Approved', 'Rejected'],
58
+ * { isDuplicate: true }
59
+ * );
60
+ *
61
+ * function determineLoanApproval(
62
+ * node?: BinaryTreeNode<string> | null,
63
+ * conditions?: { [key: string]: boolean }
64
+ * ): string {
65
+ * if (!node) throw new Error('Invalid node');
66
+ *
67
+ * // If it's a leaf node, return the decision result
68
+ * if (!node.left && !node.right) return node.key;
69
+ *
70
+ * // Check if a valid condition exists for the current node's key
71
+ * return conditions?.[node.key]
72
+ * ? determineLoanApproval(node.left, conditions)
73
+ * : determineLoanApproval(node.right, conditions);
74
+ * }
75
+ *
76
+ * // Test case 1: Stable income and good credit score
77
+ * console.log(determineLoanApproval(loanDecisionTree.root, { stableIncome: true, goodCredit: true })); // 'Approved'
78
+ *
79
+ * // Test case 2: Stable income but poor credit score
80
+ * console.log(determineLoanApproval(loanDecisionTree.root, { stableIncome: true, goodCredit: false })); // 'Rejected'
81
+ *
82
+ * // Test case 3: No stable income
83
+ * console.log(determineLoanApproval(loanDecisionTree.root, { stableIncome: false, goodCredit: true })); // 'Rejected'
84
+ *
85
+ * // Test case 4: No stable income and poor credit score
86
+ * console.log(determineLoanApproval(loanDecisionTree.root, { stableIncome: false, goodCredit: false })); // 'Rejected'
87
+ * @example
88
+ * // evaluate the arithmetic expression represented by the binary tree
89
+ * const expressionTree = new BinaryTree<number | string>(['+', 3, '*', null, null, 5, '-', null, null, 2, 8]);
90
+ *
91
+ * function evaluate(node?: BinaryTreeNode<number | string> | null): number {
92
+ * if (!node) return 0;
93
+ *
94
+ * if (typeof node.key === 'number') return node.key;
95
+ *
96
+ * const leftValue = evaluate(node.left); // Evaluate the left subtree
97
+ * const rightValue = evaluate(node.right); // Evaluate the right subtree
98
+ *
99
+ * // Perform the operation based on the current node's operator
100
+ * switch (node.key) {
101
+ * case '+':
102
+ * return leftValue + rightValue;
103
+ * case '-':
104
+ * return leftValue - rightValue;
105
+ * case '*':
106
+ * return leftValue * rightValue;
107
+ * case '/':
108
+ * return rightValue !== 0 ? leftValue / rightValue : 0; // Handle division by zero
109
+ * default:
110
+ * throw new Error(`Unsupported operator: ${node.key}`);
111
+ * }
112
+ * }
113
+ *
114
+ * console.log(evaluate(expressionTree.root)); // -27
53
115
  */
54
116
  export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any, MR = object> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, R, MK, MV, MR> {
117
+ iterationType: IterationType;
55
118
  /**
56
119
  * This TypeScript constructor function initializes a binary tree with optional options and adds
57
120
  * elements based on the provided input.
58
121
  * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
59
- * iterable that can contain either objects of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`. It
122
+ * iterable that can contain either objects of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`. It
60
123
  * is used to initialize the binary tree with keys, nodes, entries, or raw data.
61
124
  * @param [options] - The `options` parameter in the constructor is an optional object that can
62
125
  * contain the following properties:
63
126
  */
64
- constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V, BinaryTreeNode<K, V>> | R>, options?: BinaryTreeOptions<K, V, R>);
65
- iterationType: IterationType;
127
+ constructor(keysNodesEntriesOrRaws?: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, options?: BinaryTreeOptions<K, V, R>);
66
128
  protected _isMapMode: boolean;
67
129
  get isMapMode(): boolean;
130
+ protected _isDuplicate: boolean;
131
+ get isDuplicate(): boolean;
68
132
  protected _store: Map<K, V | undefined>;
69
133
  get store(): Map<K, V | undefined>;
70
- protected _root?: OptNodeOrNull<BinaryTreeNode<K, V>>;
71
- get root(): OptNodeOrNull<BinaryTreeNode<K, V>>;
134
+ protected _root?: BinaryTreeNode<K, V> | null | undefined;
135
+ get root(): BinaryTreeNode<K, V> | null | undefined;
72
136
  protected _size: number;
73
137
  get size(): number;
74
138
  protected _NIL: BinaryTreeNode<K, V>;
@@ -106,8 +170,8 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
106
170
  *
107
171
  * The function `ensureNode` in TypeScript checks if a given input is a node, entry, key, or raw
108
172
  * value and returns the corresponding node or null.
109
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
110
- * parameter in the `ensureNode` function can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`. It
173
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `keyNodeOrEntry`
174
+ * parameter in the `ensureNode` function can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`. It
111
175
  * is used to determine whether the input is a key, node, entry, or raw data. The
112
176
  * @param {IterationType} iterationType - The `iterationType` parameter in the `ensureNode` function
113
177
  * is used to specify the type of iteration to be performed. It has a default value of
@@ -115,13 +179,13 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
115
179
  * @returns The `ensureNode` function returns either a node, `null`, or `undefined` based on the
116
180
  * conditions specified in the code snippet.
117
181
  */
118
- ensureNode(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): OptNodeOrNull<BinaryTreeNode<K, V>>;
182
+ ensureNode(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): BinaryTreeNode<K, V> | null | undefined;
119
183
  /**
120
184
  * Time Complexity: O(1)
121
185
  * Space Complexity: O(1)
122
186
  *
123
187
  * The function isNode checks if the input is an instance of BinaryTreeNode.
124
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The parameter
188
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The parameter
125
189
  * `keyNodeOrEntry` can be either a key, a node, an entry, or raw data. The function is
126
190
  * checking if the input is an instance of a `BinaryTreeNode` and returning a boolean value
127
191
  * accordingly.
@@ -130,99 +194,99 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
130
194
  * it is not an instance of `BinaryTreeNode`, the function returns `false`, indicating that the input
131
195
  * is not a node.
132
196
  */
133
- isNode(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): keyNodeOrEntry is BinaryTreeNode<K, V>;
197
+ isNode(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is BinaryTreeNode<K, V>;
134
198
  /**
135
199
  * Time Complexity: O(1)
136
200
  * Space Complexity: O(1)
137
201
  *
138
202
  * The function `isRaw` checks if the input parameter is of type `R` by verifying if it is an object.
139
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | R} keyNodeEntryOrRaw - BTNRep<K, V, BinaryTreeNode<K, V>>
203
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R} keyNodeEntryOrRaw - K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined
140
204
  * @returns The function `isRaw` is checking if the `keyNodeEntryOrRaw` parameter is of type `R` by
141
205
  * checking if it is an object. If the parameter is an object, the function will return `true`,
142
206
  * indicating that it is of type `R`.
143
207
  */
144
- isRaw(keyNodeEntryOrRaw: BTNRep<K, V, BinaryTreeNode<K, V>> | R): keyNodeEntryOrRaw is R;
208
+ isRaw(keyNodeEntryOrRaw: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R): keyNodeEntryOrRaw is R;
145
209
  /**
146
210
  * Time Complexity: O(1)
147
211
  * Space Complexity: O(1)
148
212
  *
149
213
  * The function `isRealNode` checks if a given input is a valid node in a binary tree.
150
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
151
- * parameter in the `isRealNode` function can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`.
214
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `keyNodeOrEntry`
215
+ * parameter in the `isRealNode` function can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`.
152
216
  * The function checks if the input parameter is a `BinaryTreeNode<K, V>` type by verifying if it is not equal
153
217
  * @returns The function `isRealNode` is checking if the input `keyNodeOrEntry` is a valid
154
218
  * node by comparing it to `this._NIL`, `null`, and `undefined`. If the input is not one of these
155
219
  * values, it then calls the `isNode` method to further determine if the input is a node. The
156
220
  * function will return a boolean value indicating whether the
157
221
  */
158
- isRealNode(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): keyNodeOrEntry is BinaryTreeNode<K, V>;
222
+ isRealNode(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is BinaryTreeNode<K, V>;
159
223
  /**
160
224
  * Time Complexity: O(1)
161
225
  * Space Complexity: O(1)
162
226
  *
163
227
  * The function checks if a given input is a valid node or null.
164
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The parameter
228
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The parameter
165
229
  * `keyNodeOrEntry` in the `isRealNodeOrNull` function can be of type `BTNRep<K,
166
230
  * V, BinaryTreeNode<K, V>>` or `R`. It is a union type that can either be a key, a node, an entry, or
167
231
  * @returns The function `isRealNodeOrNull` is returning a boolean value. It checks if the input
168
232
  * `keyNodeOrEntry` is either `null` or a real node, and returns `true` if it is a node or
169
233
  * `null`, and `false` otherwise.
170
234
  */
171
- isRealNodeOrNull(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): keyNodeOrEntry is BinaryTreeNode<K, V> | null;
235
+ isRealNodeOrNull(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is BinaryTreeNode<K, V> | null;
172
236
  /**
173
237
  * Time Complexity: O(1)
174
238
  * Space Complexity: O(1)
175
239
  *
176
240
  * The function isNIL checks if a given key, node, entry, or raw value is equal to the _NIL value.
177
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - BTNRep<K, V,
241
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - BTNRep<K, V,
178
242
  * BinaryTreeNode<K, V>>
179
243
  * @returns The function is checking if the `keyNodeOrEntry` parameter is equal to the `_NIL`
180
244
  * property of the current object and returning a boolean value based on that comparison.
181
245
  */
182
- isNIL(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): boolean;
246
+ isNIL(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): boolean;
183
247
  /**
184
248
  * Time Complexity: O(1)
185
249
  * Space Complexity: O(1)
186
250
  *
187
251
  * The function `isRange` checks if the input parameter is an instance of the `Range` class.
188
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>> | Range<K>}
189
- * keyNodeEntryOrPredicate - The `keyNodeEntryOrPredicate` parameter in the `isRange` function can be
190
- * of type `BTNRep<K, V, BinaryTreeNode<K, V>>`, `NodePredicate<BinaryTreeNode<K, V>>`, or
252
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>> | Range<K>} keyNodeEntryOrPredicate
253
+ * - The `keyNodeEntryOrPredicate` parameter in the `isRange` function can be
254
+ * of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined `, `NodePredicate<BinaryTreeNode<K, V>>`, or
191
255
  * `Range<K>`. The function checks if the `keyNodeEntry
192
256
  * @returns The `isRange` function is checking if the `keyNodeEntryOrPredicate` parameter is an
193
257
  * instance of the `Range` class. If it is an instance of `Range`, the function will return `true`,
194
258
  * indicating that the parameter is a `Range<K>`. If it is not an instance of `Range`, the function
195
259
  * will return `false`.
196
260
  */
197
- isRange(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>> | Range<K>): keyNodeEntryOrPredicate is Range<K>;
261
+ isRange(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>> | Range<K>): keyNodeEntryOrPredicate is Range<K>;
198
262
  /**
199
263
  * Time Complexity: O(1)
200
264
  * Space Complexity: O(1)
201
265
  *
202
266
  * The function determines whether a given key, node, entry, or raw data is a leaf node in a binary
203
267
  * tree.
204
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The parameter
205
- * `keyNodeOrEntry` can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`. It represents a
268
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The parameter
269
+ * `keyNodeOrEntry` can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`. It represents a
206
270
  * key, node, entry, or raw data in a binary tree structure. The function `isLeaf` checks whether the
207
271
  * provided
208
272
  * @returns The function `isLeaf` returns a boolean value indicating whether the input
209
273
  * `keyNodeOrEntry` is a leaf node in a binary tree.
210
274
  */
211
- isLeaf(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): boolean;
275
+ isLeaf(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): boolean;
212
276
  /**
213
277
  * Time Complexity: O(1)
214
278
  * Space Complexity: O(1)
215
279
  *
216
280
  * The function `isEntry` checks if the input is a BTNEntry object by verifying if it is an array
217
281
  * with a length of 2.
218
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
219
- * parameter in the `isEntry` function can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or type `R`.
282
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `keyNodeOrEntry`
283
+ * parameter in the `isEntry` function can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or type `R`.
220
284
  * The function checks if the provided `keyNodeOrEntry` is of type `BTN
221
285
  * @returns The `isEntry` function is checking if the `keyNodeOrEntry` parameter is an array
222
286
  * with a length of 2. If it is, then it returns `true`, indicating that the parameter is of type
223
287
  * `BTNEntry<K, V>`. If the condition is not met, it returns `false`.
224
288
  */
225
- isEntry(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): keyNodeOrEntry is BTNEntry<K, V>;
289
+ isEntry(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is BTNEntry<K, V>;
226
290
  /**
227
291
  * Time Complexity O(1)
228
292
  * Space Complexity O(1)
@@ -241,7 +305,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
241
305
  *
242
306
  * The `add` function in TypeScript adds a new node to a binary tree while handling duplicate keys
243
307
  * and finding the correct insertion position.
244
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The `add` method you provided
308
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `add` method you provided
245
309
  * seems to be for adding a new node to a binary tree structure. The `keyNodeOrEntry`
246
310
  * parameter in the method can accept different types of values:
247
311
  * @param {V} [value] - The `value` parameter in the `add` method represents the value associated
@@ -252,7 +316,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
252
316
  * node was successful, and `false` if the insertion position could not be found or if a duplicate
253
317
  * key was found and the node was replaced instead of inserted.
254
318
  */
255
- add(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>, value?: V): boolean;
319
+ add(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
256
320
  /**
257
321
  * Time Complexity: O(k * n)
258
322
  * Space Complexity: O(k)
@@ -262,7 +326,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
262
326
  * each insertion was successful.
263
327
  * @param keysNodesEntriesOrRaws - `keysNodesEntriesOrRaws` is an iterable that can contain a
264
328
  * mix of keys, nodes, entries, or raw values. Each element in this iterable can be of type
265
- * `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`.
329
+ * `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`.
266
330
  * @param [values] - The `values` parameter in the `addMany` function is an optional parameter that
267
331
  * accepts an iterable of values. These values correspond to the keys or nodes being added in the
268
332
  * `keysNodesEntriesOrRaws` parameter. If provided, the function will iterate over the values and
@@ -271,7 +335,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
271
335
  * node, entry, or raw value was successfully added to the data structure. Each boolean value
272
336
  * corresponds to the success of adding the corresponding key or value in the input iterable.
273
337
  */
274
- addMany(keysNodesEntriesOrRaws: Iterable<BTNRep<K, V, BinaryTreeNode<K, V>> | R>, values?: Iterable<V | undefined>): boolean[];
338
+ addMany(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable<V | undefined>): boolean[];
275
339
  /**
276
340
  * Time Complexity: O(k * n)
277
341
  * Space Complexity: O(1)
@@ -288,19 +352,19 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
288
352
  * The `refill` function clears the existing data structure and then adds new key-value pairs based
289
353
  * on the provided input.
290
354
  * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the `refill`
291
- * method can accept an iterable containing a mix of `BTNRep<K, V, BinaryTreeNode<K, V>>` objects or `R`
355
+ * method can accept an iterable containing a mix of `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` objects or `R`
292
356
  * objects.
293
357
  * @param [values] - The `values` parameter in the `refill` method is an optional parameter that
294
358
  * accepts an iterable of values of type `V` or `undefined`.
295
359
  */
296
- refill(keysNodesEntriesOrRaws: Iterable<BTNRep<K, V, BinaryTreeNode<K, V>> | R>, values?: Iterable<V | undefined>): void;
360
+ refill(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable<V | undefined>): void;
297
361
  /**
298
362
  * Time Complexity: O(n)
299
363
  * Space Complexity: O(1)
300
364
  *
301
365
  * The function `delete` in TypeScript implements the deletion of a node in a binary tree and returns
302
366
  * the deleted node along with information for tree balancing.
303
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry
367
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry
304
368
  * - The `delete` method you provided is used to delete a node from a binary tree based on the key,
305
369
  * node, entry or raw data. The method returns an array of
306
370
  * `BinaryTreeDeleteResult` objects containing information about the deleted node and whether
@@ -309,22 +373,22 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
309
373
  * the array contains information about the node that was deleted (`deleted`) and the node that may
310
374
  * need to be balanced (`needBalanced`).
311
375
  */
312
- delete(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
376
+ delete(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
313
377
  /**
314
378
  * Time Complexity: O(n)
315
379
  * Space Complexity: O(k + log n)
316
380
  *
317
381
  * The `search` function in TypeScript performs a depth-first or breadth-first search on a tree
318
382
  * structure based on a given predicate or key, with options to return multiple results or just one.
319
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate - The
383
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate - The
320
384
  * `keyNodeEntryOrPredicate` parameter in the `search` function can accept three types of values:
321
385
  * @param [onlyOne=false] - The `onlyOne` parameter in the `search` function is a boolean flag that
322
386
  * determines whether the search should stop after finding the first matching node. If `onlyOne` is
323
387
  * set to `true`, the search will return as soon as a matching node is found. If `onlyOne` is
324
388
  * @param {C} callback - The `callback` parameter in the `search` function is a callback function
325
389
  * that will be called on each node that matches the search criteria. It is of type `C`, which
326
- * extends `NodeCallback<BinaryTreeNode<K, V>>`. The default value for `callback` is `this._DEFAULT_NODE_CALLBACK` if
327
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `search` function is
390
+ * extends `NodeCallback<BinaryTreeNode<K, V> | null>`. The default value for `callback` is `this._DEFAULT_NODE_CALLBACK` if
391
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the `search` function is
328
392
  * used to specify the node from which the search operation should begin. It represents the starting
329
393
  * point in the binary tree where the search will be performed. If no specific `startNode` is
330
394
  * provided, the search operation will start from the root
@@ -334,39 +398,18 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
334
398
  * @returns The `search` function returns an array of values that match the provided criteria based
335
399
  * on the search algorithm implemented within the function.
336
400
  */
337
- search<C extends NodeCallback<BinaryTreeNode<K, V>>>(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>, onlyOne?: boolean, callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): ReturnType<C>[];
338
- /**
339
- * Time Complexity: O(n)
340
- * Space Complexity: O(k + log n)
341
- *
342
- * The function `getNodes` retrieves nodes from a binary tree based on a key, node, entry, raw data,
343
- * or predicate, with options for recursive or iterative traversal.
344
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
345
- * - The `getNodes` function you provided takes several parameters:
346
- * @param [onlyOne=false] - The `onlyOne` parameter in the `getNodes` function is a boolean flag that
347
- * determines whether to return only the first node that matches the criteria specified by the
348
- * `keyNodeEntryOrPredicate` parameter. If `onlyOne` is set to `true`, the function will
349
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
350
- * `getNodes` function is used to specify the starting point for traversing the binary tree. It
351
- * represents the root node of the binary tree or the node from which the traversal should begin. If
352
- * not provided, the default value is set to `this._root
353
- * @param {IterationType} iterationType - The `iterationType` parameter in the `getNodes` function
354
- * determines the type of iteration to be performed when traversing the nodes of a binary tree. It
355
- * can have two possible values:
356
- * @returns The `getNodes` function returns an array of nodes that satisfy the provided condition
357
- * based on the input parameters and the iteration type specified.
358
- */
359
- getNodes(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>, onlyOne?: boolean, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): BinaryTreeNode<K, V>[];
401
+ search<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V> | null>, onlyOne?: boolean, callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[];
402
+ getNodes(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>, onlyOne?: boolean, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): BinaryTreeNode<K, V>[];
360
403
  /**
361
404
  * Time Complexity: O(n)
362
405
  * Space Complexity: O(log n)
363
406
  *
364
407
  * The `getNode` function retrieves a node based on the provided key, node, entry, raw data, or
365
408
  * predicate.
366
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
409
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
367
410
  * - The `keyNodeEntryOrPredicate` parameter in the `getNode` function can accept a key,
368
411
  * node, entry, raw data, or a predicate function.
369
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
412
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
370
413
  * `getNode` function is used to specify the starting point for searching for a node in a binary
371
414
  * tree. If no specific starting point is provided, the default value is set to `this._root`, which
372
415
  * is typically the root node of the binary tree.
@@ -377,17 +420,17 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
377
420
  * @returns The `getNode` function is returning the first node that matches the specified criteria,
378
421
  * or `null` if no matching node is found.
379
422
  */
380
- getNode(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): OptNodeOrNull<BinaryTreeNode<K, V>>;
423
+ getNode(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V> | null>, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): BinaryTreeNode<K, V> | null | undefined;
381
424
  /**
382
425
  * Time Complexity: O(n)
383
426
  * Space Complexity: O(log n)
384
427
  *
385
428
  * This function overrides the `get` method to retrieve the value associated with a specified key,
386
429
  * node, entry, raw data, or predicate in a data structure.
387
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
430
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
388
431
  * - The `keyNodeEntryOrPredicate` parameter in the `get` method can accept one of the
389
432
  * following types:
390
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `get`
433
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the `get`
391
434
  * method is used to specify the starting point for searching for a key or node in the binary tree.
392
435
  * If no specific starting point is provided, the default starting point is the root of the binary
393
436
  * tree (`this._root`).
@@ -400,29 +443,8 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
400
443
  * the method returns the corresponding value. If the key or node is not found, it returns
401
444
  * `undefined`.
402
445
  */
403
- get(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>>, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): V | undefined;
404
- /**
405
- * Time Complexity: O(n)
406
- * Space Complexity: O(log n)
407
- *
408
- * The `has` function in TypeScript checks if a specified key, node, entry, raw data, or predicate
409
- * exists in the data structure.
410
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
411
- * - The `keyNodeEntryOrPredicate` parameter in the `override has` method can accept one of
412
- * the following types:
413
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
414
- * `override` method is used to specify the starting point for the search operation within the data
415
- * structure. It defaults to `this._root` if not provided explicitly.
416
- * @param {IterationType} iterationType - The `iterationType` parameter in the `override has` method
417
- * is used to specify the type of iteration to be performed. It has a default value of
418
- * `this.iterationType`, which means it will use the iteration type defined in the current context if
419
- * no value is provided when calling the method.
420
- * @returns The `override has` method is returning a boolean value. It checks if there are any nodes
421
- * that match the provided key, node, entry, raw data, or predicate in the tree structure. If there
422
- * are matching nodes, it returns `true`, indicating that the tree contains the specified element.
423
- * Otherwise, it returns `false`.
424
- */
425
- has(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): boolean;
446
+ get(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): V | undefined;
447
+ has(keyNodeEntryOrPredicate?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): boolean;
426
448
  /**
427
449
  * Time Complexity: O(1)
428
450
  * Space Complexity: O(1)
@@ -446,7 +468,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
446
468
  *
447
469
  * The function checks if a binary tree is perfectly balanced by comparing its minimum height with
448
470
  * its height.
449
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter is the starting
471
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter is the starting
450
472
  * point for checking if the binary tree is perfectly balanced. It represents the root node of the
451
473
  * binary tree or a specific node from which the balance check should begin.
452
474
  * @returns The method `isPerfectlyBalanced` is returning a boolean value, which indicates whether
@@ -455,14 +477,14 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
455
477
  * height plus 1 is greater than or equal to the height of the tree, then it is considered perfectly
456
478
  * balanced and
457
479
  */
458
- isPerfectlyBalanced(startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>): boolean;
480
+ isPerfectlyBalanced(startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): boolean;
459
481
  /**
460
482
  * Time Complexity: O(n)
461
483
  * Space Complexity: O(log n)
462
484
  *
463
485
  * The function `isBST` in TypeScript checks if a binary search tree is valid using either recursive
464
486
  * or iterative methods.
465
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `isBST`
487
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the `isBST`
466
488
  * function represents the starting point for checking whether a binary search tree (BST) is valid.
467
489
  * It can be a node in the BST or a reference to the root of the BST. If no specific node is
468
490
  * provided, the function will default to
@@ -474,16 +496,16 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
474
496
  * the tree satisfies the BST property, where for every node, all nodes in its left subtree have keys
475
497
  * less than the node's key, and all nodes in its right subtree have keys greater than the node's
476
498
  */
477
- isBST(startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): boolean;
499
+ isBST(startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): boolean;
478
500
  /**
479
501
  * Time Complexity: O(n)
480
502
  * Space Complexity: O(log n)
481
503
  *
482
504
  * The `getDepth` function calculates the depth between two nodes in a binary tree.
483
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} dist - The `dist` parameter in the `getDepth`
505
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } dist - The `dist` parameter in the `getDepth`
484
506
  * function represents the node or entry in a binary tree map, or a reference to a node in the tree.
485
507
  * It is the target node for which you want to calculate the depth from the `startNode` node.
486
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
508
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
487
509
  * `getDepth` function represents the starting point from which you want to calculate the depth of a
488
510
  * given node or entry in a binary tree. If no specific starting point is provided, the default value
489
511
  * for `startNode` is set to the root of the binary
@@ -491,14 +513,14 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
491
513
  * `startNode` node in a binary tree. If the `dist` node is not found in the path to the `startNode`
492
514
  * node, it returns the depth of the `dist` node from the root of the tree.
493
515
  */
494
- getDepth(dist: BTNRep<K, V, BinaryTreeNode<K, V>>, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>): number;
516
+ getDepth(dist: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): number;
495
517
  /**
496
518
  * Time Complexity: O(n)
497
519
  * Space Complexity: O(log n)
498
520
  *
499
521
  * The `getHeight` function calculates the maximum height of a binary tree using either a recursive
500
522
  * or iterative approach in TypeScript.
501
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter is the starting
523
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter is the starting
502
524
  * point from which the height of the binary tree will be calculated. It can be a node in the binary
503
525
  * tree or a reference to the root of the tree. If not provided, it defaults to the root of the
504
526
  * binary tree data structure.
@@ -509,14 +531,14 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
509
531
  * root node. The height is calculated based on the maximum depth of the tree, considering either a
510
532
  * recursive approach or an iterative approach depending on the `iterationType` parameter.
511
533
  */
512
- getHeight(startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): number;
534
+ getHeight(startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): number;
513
535
  /**
514
536
  * Time Complexity: O(n)
515
537
  * Space Complexity: O(log n)
516
538
  *
517
539
  * The `getMinHeight` function calculates the minimum height of a binary tree using either a
518
540
  * recursive or iterative approach in TypeScript.
519
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
541
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
520
542
  * `getMinHeight` function represents the starting node from which the minimum height of the binary
521
543
  * tree will be calculated. It is either a node in the binary tree or a reference to the root of the
522
544
  * tree. If not provided, the default value is the root
@@ -528,7 +550,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
528
550
  * leaf node in the tree. The method uses either a recursive approach or an iterative approach (using
529
551
  * a stack) based on the `iterationType` parameter.
530
552
  */
531
- getMinHeight(startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): number;
553
+ getMinHeight(startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): number;
532
554
  /**
533
555
  * Time Complexity: O(log n)
534
556
  * Space Complexity: O(log n)
@@ -539,7 +561,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
539
561
  * the path to the root. It is expected to be a function that takes a node as an argument and returns
540
562
  * a value based on that node. The return type of the callback function is determined by the generic
541
563
  * type `C
542
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} beginNode - The `beginNode` parameter in the
564
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } beginNode - The `beginNode` parameter in the
543
565
  * `getPathToRoot` function can be either a key, a node, an entry, or any other value of type `R`.
544
566
  * @param [isReverse=true] - The `isReverse` parameter in the `getPathToRoot` function determines
545
567
  * whether the resulting path from the given `beginNode` to the root should be in reverse order or
@@ -549,7 +571,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
549
571
  * array is either in reverse order or in the original order based on the value of the `isReverse`
550
572
  * parameter.
551
573
  */
552
- getPathToRoot<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(beginNode: BTNRep<K, V, BinaryTreeNode<K, V>>, callback?: C, isReverse?: boolean): ReturnType<C>[];
574
+ getPathToRoot<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(beginNode: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, callback?: C, isReverse?: boolean): ReturnType<C>[];
553
575
  /**
554
576
  * Time Complexity: O(log n)
555
577
  * Space Complexity: O(log n)
@@ -559,7 +581,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
559
581
  * @param {C} callback - The `callback` parameter is a function that will be called with the leftmost
560
582
  * node of a binary tree or with `undefined` if the tree is empty. It is provided with a default
561
583
  * value of `_DEFAULT_NODE_CALLBACK` if not specified.
562
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
584
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
563
585
  * `getLeftMost` function represents the starting point for finding the leftmost node in a binary
564
586
  * tree. It can be either a key, a node, or an entry in the binary tree structure. If no specific
565
587
  * starting point is provided, the function will default
@@ -571,7 +593,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
571
593
  * `NIL`, it returns the result of the callback function applied to `undefined`. If the `startNode`
572
594
  * node is not a real node, it returns the result of the callback
573
595
  */
574
- getLeftMost<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): ReturnType<C>;
596
+ getLeftMost<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>;
575
597
  /**
576
598
  * Time Complexity: O(log n)
577
599
  * Space Complexity: O(log n)
@@ -582,7 +604,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
582
604
  * of finding the rightmost node in a binary tree. It is of type `NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>`,
583
605
  * which means it is a callback function that can accept either an optional binary tree node or null
584
606
  * as
585
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
607
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
586
608
  * `getRightMost` function represents the starting point for finding the rightmost node in a binary
587
609
  * tree. It can be either a key, a node, or an entry in the binary tree structure. If no specific
588
610
  * starting point is provided, the function will default
@@ -594,7 +616,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
594
616
  * the binary tree structure, determined based on the specified iteration type ('RECURSIVE' or
595
617
  * other).
596
618
  */
597
- getRightMost<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): ReturnType<C>;
619
+ getRightMost<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>;
598
620
  /**
599
621
  * Time Complexity: O(log n)
600
622
  * Space Complexity: O(log n)
@@ -622,11 +644,11 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
622
644
  * have a right child, the function traverses up the parent nodes until it finds a node that is not
623
645
  * the right child of its parent, and returns that node
624
646
  */
625
- getSuccessor(x?: K | BinaryTreeNode<K, V> | null): OptNodeOrNull<BinaryTreeNode<K, V>>;
626
- dfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, pattern?: DFSOrderPattern, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): ReturnType<C>[];
627
- dfs<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, pattern?: DFSOrderPattern, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: boolean): ReturnType<C>[];
628
- bfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
629
- bfs<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
647
+ getSuccessor(x?: K | BinaryTreeNode<K, V> | null): BinaryTreeNode<K, V> | null | undefined;
648
+ dfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, pattern?: DFSOrderPattern, onlyOne?: boolean, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[];
649
+ dfs<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, pattern?: DFSOrderPattern, onlyOne?: boolean, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: boolean): ReturnType<C>[];
650
+ bfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
651
+ bfs<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
630
652
  /**
631
653
  * Time complexity: O(n)
632
654
  * Space complexity: O(n)
@@ -635,7 +657,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
635
657
  * structure based on a specified callback and iteration type.
636
658
  * @param {C} callback - The `callback` parameter is a function that will be called on each leaf node
637
659
  * in the binary tree. It is optional and defaults to a default callback function if not provided.
638
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `leaves`
660
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the `leaves`
639
661
  * method is used to specify the starting point for finding and processing the leaves of a binary
640
662
  * tree. It can be provided as either a key, a node, or an entry in the binary tree structure. If not
641
663
  * explicitly provided, the default value
@@ -645,30 +667,10 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
645
667
  * @returns The `leaves` method returns an array of values that are the result of applying the
646
668
  * provided callback function to each leaf node in the binary tree.
647
669
  */
648
- leaves<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): ReturnType<C>[];
649
- listLevels<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
650
- listLevels<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
651
- /**
652
- * Time complexity: O(n)
653
- * Space complexity: O(n)
654
- *
655
- * The `morris` function in TypeScript performs a Depth-First Search traversal on a binary tree using
656
- * Morris Traversal algorithm with different order patterns.
657
- * @param {C} callback - The `callback` parameter in the `morris` function is a function that will be
658
- * called on each node in the binary tree during the traversal. It is of type `C`, which extends the
659
- * `NodeCallback<BinaryTreeNode<K, V>>` type. The default value for `callback` is `this._DEFAULT
660
- * @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter in the `morris` function specifies
661
- * the type of Depth-First Search (DFS) order pattern to traverse the binary tree. The possible
662
- * values for the `pattern` parameter are:
663
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `morris`
664
- * function is the starting point for the Morris traversal algorithm. It represents the root node of
665
- * the binary tree or the node from which the traversal should begin. It can be provided as either a
666
- * key, a node, an entry, or a reference
667
- * @returns The `morris` function is returning an array of values that are the result of applying the
668
- * provided callback function to each node in the binary tree in the specified order pattern (IN,
669
- * PRE, or POST).
670
- */
671
- morris<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, pattern?: DFSOrderPattern, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>): ReturnType<C>[];
670
+ leaves<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[];
671
+ listLevels<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
672
+ listLevels<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
673
+ morris<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, pattern?: DFSOrderPattern, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): ReturnType<C>[];
672
674
  /**
673
675
  * Time complexity: O(n)
674
676
  * Space complexity: O(n)
@@ -681,7 +683,6 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
681
683
  * the original tree is null, a null node is added to the cloned tree. If a node
682
684
  */
683
685
  clone(): BinaryTree<K, V, R, MK, MV, MR>;
684
- protected _clone(cloned: BinaryTree<K, V, R, MK, MV, MR>): void;
685
686
  /**
686
687
  * Time Complexity: O(n)
687
688
  * Space Complexity: O(n)
@@ -725,7 +726,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
725
726
  *
726
727
  * The function `toVisual` in TypeScript overrides the visual representation of a binary tree with
727
728
  * customizable options for displaying undefined, null, and sentinel nodes.
728
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
729
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
729
730
  * `toVisual` method is used to specify the starting point for visualizing the binary tree structure.
730
731
  * It can be a node, key, entry, or the root of the tree. If no specific starting point is provided,
731
732
  * the default is set to the root
@@ -737,7 +738,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
737
738
  * the lines to the output string. The final output string contains the visual representation of the
738
739
  * binary tree with the specified options.
739
740
  */
740
- toVisual(startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, options?: BinaryTreePrintOptions): string;
741
+ toVisual(startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, options?: BinaryTreePrintOptions): string;
741
742
  /**
742
743
  * Time Complexity: O(n)
743
744
  * Space Complexity: O(n)
@@ -748,74 +749,33 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
748
749
  * printing options for the binary tree. It is an optional parameter that allows you to customize how
749
750
  * the binary tree is printed, such as choosing between different traversal orders or formatting
750
751
  * options.
751
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
752
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
752
753
  * `override print` method is used to specify the starting point for printing the binary tree. It can
753
754
  * be either a key, a node, an entry, or the root of the tree. If no specific starting point is
754
755
  * provided, the default value is set to
755
756
  */
756
- print(options?: BinaryTreePrintOptions, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>): void;
757
+ print(options?: BinaryTreePrintOptions, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): void;
758
+ protected _clone(cloned: BinaryTree<K, V, R, MK, MV, MR>): void;
757
759
  /**
758
760
  * Time Complexity: O(1)
759
761
  * Space Complexity: O(1)
760
762
  *
761
763
  * The function `keyValueNodeEntryRawToNodeAndValue` converts various input types into a node object
762
764
  * or returns null.
763
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The
765
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The
764
766
  * `keyValueNodeEntryRawToNodeAndValue` function takes in a parameter `keyNodeOrEntry`, which
765
- * can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`. This parameter represents either a key, a
767
+ * can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`. This parameter represents either a key, a
766
768
  * node, an entry
767
769
  * @param {V} [value] - The `value` parameter in the `keyValueNodeEntryRawToNodeAndValue` function is
768
770
  * an optional parameter of type `V`. It represents the value associated with the key in the node
769
771
  * being created. If a `value` is provided, it will be used when creating the node. If
770
772
  * @returns The `keyValueNodeEntryRawToNodeAndValue` function returns an optional node
771
- * (`OptNodeOrNull<BinaryTreeNode<K, V>>`) based on the input parameters provided. The function checks the type of the
773
+ * (`BinaryTreeNode<K, V> | null | undefined`) based on the input parameters provided. The function checks the type of the
772
774
  * input parameter (`keyNodeOrEntry`) and processes it accordingly to return a node or null
773
775
  * value.
774
776
  */
775
- protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>, value?: V): [OptNodeOrNull<BinaryTreeNode<K, V>>, V | undefined];
776
- /**
777
- * Time complexity: O(n)
778
- * Space complexity: O(n)
779
- *
780
- * The `_dfs` function performs a depth-first search traversal on a binary tree structure based on
781
- * the specified order pattern and callback function.
782
- * @param {C} callback - The `callback` parameter in the `_dfs` method is a function that will be
783
- * called on each node visited during the depth-first search traversal. It is of type `C`, which
784
- * extends `NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>`. The default value for this parameter is `this._DEFAULT
785
- * @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter in the `_dfs` method specifies the
786
- * order in which the nodes are visited during the Depth-First Search traversal. It can have one of
787
- * the following values:
788
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `_dfs`
789
- * method is used to specify the starting point for the depth-first search traversal in a binary
790
- * tree. It can be provided as either a `BTNRep` object or a reference to the root node
791
- * of the tree. If no specific
792
- * @param {IterationType} iterationType - The `iterationType` parameter in the `_dfs` method
793
- * specifies the type of iteration to be performed during the Depth-First Search (DFS) traversal of a
794
- * binary tree. It can have two possible values:
795
- * @param [includeNull=false] - The `includeNull` parameter in the `_dfs` method is a boolean flag
796
- * that determines whether null nodes should be included in the depth-first search traversal. If
797
- * `includeNull` is set to `true`, null nodes will be considered during the traversal process. If it
798
- * is set to `false`,
799
- * @param shouldVisitLeft - The `shouldVisitLeft` parameter is a function that takes a node as input
800
- * and returns a boolean value. It is used to determine whether the left child of a node should be
801
- * visited during the depth-first search traversal. By default, it checks if the node is truthy (not
802
- * null or undefined
803
- * @param shouldVisitRight - The `shouldVisitRight` parameter is a function that takes a node as an
804
- * argument and returns a boolean value. It is used to determine whether the right child of a node
805
- * should be visited during the depth-first search traversal. The default implementation checks if
806
- * the node is truthy before visiting the right child
807
- * @param shouldVisitRoot - The `shouldVisitRoot` parameter is a function that takes a node as an
808
- * argument and returns a boolean value. It is used to determine whether the root node should be
809
- * visited during the depth-first search traversal based on certain conditions. The default
810
- * implementation checks if the node is a real node or null based
811
- * @param shouldProcessRoot - The `shouldProcessRoot` parameter is a function that takes a node as an
812
- * argument and returns a boolean value indicating whether the node should be processed during the
813
- * depth-first search traversal. The default implementation checks if the node is a real node or null
814
- * based on the `includeNull` flag. If `
815
- * @returns The function `_dfs` returns an array of the return type of the callback function provided
816
- * as input.
817
- */
818
- protected _dfs<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(callback?: C, pattern?: DFSOrderPattern, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: boolean, shouldVisitLeft?: (node: OptNodeOrNull<BinaryTreeNode<K, V>>) => boolean, shouldVisitRight?: (node: OptNodeOrNull<BinaryTreeNode<K, V>>) => boolean, shouldVisitRoot?: (node: OptNodeOrNull<BinaryTreeNode<K, V>>) => boolean, shouldProcessRoot?: (node: OptNodeOrNull<BinaryTreeNode<K, V>>) => boolean): ReturnType<C>[];
777
+ protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): [BinaryTreeNode<K, V> | null | undefined, V | undefined];
778
+ protected _dfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback: C, pattern?: DFSOrderPattern, onlyOne?: boolean, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: boolean, shouldVisitLeft?: (node: BinaryTreeNode<K, V> | null | undefined) => boolean, shouldVisitRight?: (node: BinaryTreeNode<K, V> | null | undefined) => boolean, shouldVisitRoot?: (node: BinaryTreeNode<K, V> | null | undefined) => boolean, shouldProcessRoot?: (node: BinaryTreeNode<K, V> | null | undefined) => boolean): ReturnType<C>[];
819
779
  /**
820
780
  * Time Complexity: O(1)
821
781
  * Space Complexity: O(1)
@@ -831,7 +791,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
831
791
  * the `iterationType` property. If the `iterationType` is set to 'ITERATIVE', the method uses a
832
792
  * stack to perform an in-order traversal of the tree. If the `iterationType` is not 'ITERATIVE
833
793
  */
834
- protected _getIterator(node?: OptNodeOrNull<BinaryTreeNode<K, V>>): IterableIterator<[K, V | undefined]>;
794
+ protected _getIterator(node?: BinaryTreeNode<K, V> | null | undefined): IterableIterator<[K, V | undefined]>;
835
795
  /**
836
796
  * Time Complexity: O(n)
837
797
  * Space Complexity: O(n)
@@ -847,24 +807,24 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
847
807
  * information about how to display a node in a binary tree. The `NodeDisplayLayout` consists of four
848
808
  * elements:
849
809
  */
850
- protected _displayAux(node: OptNodeOrNull<BinaryTreeNode<K, V>>, options: BinaryTreePrintOptions): NodeDisplayLayout;
851
- protected _DEFAULT_NODE_CALLBACK: (node: OptNodeOrNull<BinaryTreeNode<K, V>>) => K | undefined;
810
+ protected _displayAux(node: BinaryTreeNode<K, V> | null | undefined, options: BinaryTreePrintOptions): NodeDisplayLayout;
811
+ protected _DEFAULT_NODE_CALLBACK: (node: BinaryTreeNode<K, V> | null | undefined) => K | undefined;
852
812
  /**
853
813
  * Time Complexity: O(1)
854
814
  * Space Complexity: O(1)
855
815
  *
856
816
  * The _swapProperties function swaps key and value properties between two nodes in a binary tree.
857
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} srcNode - The `srcNode` parameter in the
817
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } srcNode - The `srcNode` parameter in the
858
818
  * `_swapProperties` method can be either a BTNRep object containing key and value
859
819
  * properties, or it can be of type R.
860
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} destNode - The `destNode` parameter in the
820
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } destNode - The `destNode` parameter in the
861
821
  * `_swapProperties` method represents the node or entry where the properties will be swapped with
862
- * the `srcNode`. It can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`. The method ensures that
822
+ * the `srcNode`. It can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`. The method ensures that
863
823
  * both `srcNode
864
824
  * @returns The `_swapProperties` method returns either the `destNode` with its key and value swapped
865
825
  * with the `srcNode`, or `undefined` if either `srcNode` or `destNode` is falsy.
866
826
  */
867
- protected _swapProperties(srcNode: BTNRep<K, V, BinaryTreeNode<K, V>>, destNode: BTNRep<K, V, BinaryTreeNode<K, V>>): BinaryTreeNode<K, V> | undefined;
827
+ protected _swapProperties(srcNode: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, destNode: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): BinaryTreeNode<K, V> | undefined;
868
828
  /**
869
829
  * Time Complexity: O(1)
870
830
  * Space Complexity: O(1)
@@ -886,23 +846,11 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
886
846
  *
887
847
  * The function _setRoot sets the root node of a data structure while updating the parent reference
888
848
  * of the previous root node.
889
- * @param v - The parameter `v` in the `_setRoot` method is of type `OptNodeOrNull<BinaryTreeNode<K, V>>`, which means
849
+ * @param v - The parameter `v` in the `_setRoot` method is of type `BinaryTreeNode<K, V> | null | undefined`, which means
890
850
  * it can either be an optional `BinaryTreeNode<K, V>` type or `null`.
891
851
  */
892
- protected _setRoot(v: OptNodeOrNull<BinaryTreeNode<K, V>>): void;
893
- /**
894
- * Time Complexity: O(1)
895
- * Space Complexity: O(1)
896
- *
897
- * The function `_ensurePredicate` in TypeScript ensures that the input is converted into a valid
898
- * predicate function for a binary tree node.
899
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate - The
900
- * `_ensurePredicate` method in the provided code snippet is responsible for ensuring that the input
901
- * parameter `keyNodeEntryOrPredicate` is transformed into a valid predicate function that can be
902
- * used for filtering nodes in a binary tree.
903
- * @returns A NodePredicate<BinaryTreeNode<K, V>> function is being returned.
904
- */
905
- protected _ensurePredicate(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>): NodePredicate<BinaryTreeNode<K, V>>;
852
+ protected _setRoot(v: BinaryTreeNode<K, V> | null | undefined): void;
853
+ protected _ensurePredicate(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>): NodePredicate<BinaryTreeNode<K, V>>;
906
854
  /**
907
855
  * Time Complexity: O(1)
908
856
  * Space Complexity: O(1)
@@ -922,14 +870,14 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
922
870
  *
923
871
  * The function `_extractKey` in TypeScript returns the key from a given input, which can be a node,
924
872
  * entry, raw data, or null/undefined.
925
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The `_extractKey` method you provided is a
926
- * TypeScript method that takes in a parameter `keyNodeOrEntry` of type `BTNRep<K, V, BinaryTreeNode<K, V>>`,
873
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `_extractKey` method you provided is a
874
+ * TypeScript method that takes in a parameter `keyNodeOrEntry` of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined `,
927
875
  * where `BTNRep` is a generic type with keys `K`, `V`, and `BinaryTreeNode<K, V>`, and `
928
876
  * @returns The `_extractKey` method returns the key value extracted from the `keyNodeOrEntry`
929
877
  * parameter. The return value can be a key value of type `K`, `null`, or `undefined`, depending on
930
878
  * the conditions checked in the method.
931
879
  */
932
- protected _extractKey(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): K | null | undefined;
880
+ protected _extractKey(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): K | null | undefined;
933
881
  /**
934
882
  * Time Complexity: O(1)
935
883
  * Space Complexity: O(1)