min-heap-typed 1.50.1 → 1.50.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +114 -9
  2. package/dist/data-structures/base/iterable-base.js +143 -7
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +43 -46
  4. package/dist/data-structures/binary-tree/avl-tree.js +68 -71
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +244 -199
  6. package/dist/data-structures/binary-tree/binary-tree.js +484 -376
  7. package/dist/data-structures/binary-tree/bst.d.ts +54 -74
  8. package/dist/data-structures/binary-tree/bst.js +30 -71
  9. package/dist/data-structures/binary-tree/rb-tree.d.ts +78 -60
  10. package/dist/data-structures/binary-tree/rb-tree.js +84 -89
  11. package/dist/data-structures/binary-tree/tree-multimap.d.ts +37 -56
  12. package/dist/data-structures/binary-tree/tree-multimap.js +64 -85
  13. package/dist/data-structures/graph/abstract-graph.d.ts +1 -0
  14. package/dist/data-structures/graph/abstract-graph.js +3 -0
  15. package/dist/data-structures/graph/directed-graph.d.ts +14 -0
  16. package/dist/data-structures/graph/directed-graph.js +26 -0
  17. package/dist/data-structures/graph/map-graph.d.ts +8 -0
  18. package/dist/data-structures/graph/map-graph.js +14 -0
  19. package/dist/data-structures/graph/undirected-graph.d.ts +16 -0
  20. package/dist/data-structures/graph/undirected-graph.js +25 -0
  21. package/dist/data-structures/hash/hash-map.d.ts +121 -15
  22. package/dist/data-structures/hash/hash-map.js +160 -25
  23. package/dist/data-structures/heap/heap.d.ts +66 -6
  24. package/dist/data-structures/heap/heap.js +66 -6
  25. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +67 -50
  26. package/dist/data-structures/linked-list/doubly-linked-list.js +70 -64
  27. package/dist/data-structures/linked-list/singly-linked-list.d.ts +128 -103
  28. package/dist/data-structures/linked-list/singly-linked-list.js +130 -112
  29. package/dist/data-structures/linked-list/skip-linked-list.d.ts +63 -36
  30. package/dist/data-structures/linked-list/skip-linked-list.js +63 -36
  31. package/dist/data-structures/matrix/matrix.d.ts +35 -4
  32. package/dist/data-structures/matrix/matrix.js +50 -11
  33. package/dist/data-structures/queue/deque.d.ts +49 -19
  34. package/dist/data-structures/queue/deque.js +101 -47
  35. package/dist/data-structures/queue/queue.d.ts +39 -5
  36. package/dist/data-structures/queue/queue.js +47 -5
  37. package/dist/data-structures/stack/stack.d.ts +16 -0
  38. package/dist/data-structures/stack/stack.js +22 -0
  39. package/dist/data-structures/trie/trie.d.ts +38 -1
  40. package/dist/data-structures/trie/trie.js +41 -0
  41. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  42. package/dist/types/data-structures/hash/hash-map.d.ts +4 -3
  43. package/dist/types/utils/utils.d.ts +1 -0
  44. package/package.json +2 -2
  45. package/src/data-structures/base/iterable-base.ts +172 -19
  46. package/src/data-structures/binary-tree/avl-tree.ts +97 -97
  47. package/src/data-structures/binary-tree/binary-tree.ts +674 -671
  48. package/src/data-structures/binary-tree/bst.ts +89 -131
  49. package/src/data-structures/binary-tree/rb-tree.ts +127 -155
  50. package/src/data-structures/binary-tree/tree-multimap.ts +96 -112
  51. package/src/data-structures/graph/abstract-graph.ts +4 -0
  52. package/src/data-structures/graph/directed-graph.ts +30 -0
  53. package/src/data-structures/graph/map-graph.ts +15 -0
  54. package/src/data-structures/graph/undirected-graph.ts +28 -0
  55. package/src/data-structures/hash/hash-map.ts +175 -34
  56. package/src/data-structures/heap/heap.ts +66 -6
  57. package/src/data-structures/linked-list/doubly-linked-list.ts +72 -66
  58. package/src/data-structures/linked-list/singly-linked-list.ts +132 -114
  59. package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
  60. package/src/data-structures/matrix/matrix.ts +52 -12
  61. package/src/data-structures/queue/deque.ts +108 -49
  62. package/src/data-structures/queue/queue.ts +51 -5
  63. package/src/data-structures/stack/stack.ts +24 -0
  64. package/src/data-structures/trie/trie.ts +45 -1
  65. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  66. package/src/types/data-structures/hash/hash-map.ts +4 -3
  67. package/src/types/utils/utils.ts +2 -0
@@ -12,19 +12,47 @@ import { IterableEntryBase } from '../base';
12
12
  /**
13
13
  * Represents a node in a binary tree.
14
14
  * @template V - The type of data stored in the node.
15
- * @template N - The type of the family relationship in the binary tree.
15
+ * @template NODE - The type of the family relationship in the binary tree.
16
16
  */
17
- export declare class BinaryTreeNode<K = any, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>> {
17
+ export declare class BinaryTreeNode<K = any, V = any, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>> {
18
18
  key: K;
19
19
  value?: V;
20
- parent?: N;
20
+ parent?: NODE;
21
+ /**
22
+ * The constructor function initializes an object with a key and an optional value.
23
+ * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
24
+ * constructor. It is used to set the value of the "key" property of the object being created.
25
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
26
+ * value associated with the key in the constructor.
27
+ */
21
28
  constructor(key: K, value?: V);
22
- protected _left?: N | null;
23
- get left(): N | null | undefined;
24
- set left(v: N | null | undefined);
25
- protected _right?: N | null;
26
- get right(): N | null | undefined;
27
- set right(v: N | null | undefined);
29
+ protected _left?: NODE | null;
30
+ /**
31
+ * The function returns the value of the `_left` property, which can be of type `NODE`, `null`, or
32
+ * `undefined`.
33
+ * @returns The left node of the current node is being returned. It can be either a NODE object,
34
+ * null, or undefined.
35
+ */
36
+ get left(): NODE | null | undefined;
37
+ /**
38
+ * The function sets the left child of a node and updates its parent reference.
39
+ * @param {NODE | null | undefined} v - The parameter `v` can be of type `NODE`, `null`, or
40
+ * `undefined`.
41
+ */
42
+ set left(v: NODE | null | undefined);
43
+ protected _right?: NODE | null;
44
+ /**
45
+ * The function returns the right node of a binary tree or null if it doesn't exist.
46
+ * @returns The method is returning the value of the `_right` property, which can be a `NODE` object,
47
+ * `null`, or `undefined`.
48
+ */
49
+ get right(): NODE | null | undefined;
50
+ /**
51
+ * The function sets the right child of a node and updates its parent.
52
+ * @param {NODE | null | undefined} v - The parameter `v` can be of type `NODE`, `null`, or
53
+ * `undefined`.
54
+ */
55
+ set right(v: NODE | null | undefined);
28
56
  /**
29
57
  * Get the position of the node within its family.
30
58
  * @returns {FamilyPosition} - The family position of the node.
@@ -38,7 +66,7 @@ export declare class BinaryTreeNode<K = any, V = any, N extends BinaryTreeNode<K
38
66
  * 4. Subtrees: Each child of a node forms the root of a subtree.
39
67
  * 5. Leaf Nodes: Nodes without children are leaves.
40
68
  */
41
- export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTree<K, V, N, BinaryTreeNested<K, V, N>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, N, TREE> {
69
+ export declare class BinaryTree<K = any, V = any, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, NODE, TREE> = BinaryTree<K, V, NODE, BinaryTreeNested<K, V, NODE>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, NODE, TREE> {
42
70
  iterationType: IterationType;
43
71
  /**
44
72
  * The constructor function initializes a binary tree object with optional keysOrNodesOrEntries and options.
@@ -49,20 +77,33 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
49
77
  * `Partial<BinaryTreeOptions>`, which means that not all properties of `BinaryTreeOptions` are
50
78
  * required.
51
79
  */
52
- constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, N>>, options?: BinaryTreeOptions<K>);
80
+ constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: BinaryTreeOptions<K>);
53
81
  protected _extractor: (key: K) => number;
82
+ /**
83
+ * The function returns the value of the `_extractor` property.
84
+ * @returns The `_extractor` property is being returned.
85
+ */
54
86
  get extractor(): (key: K) => number;
55
- protected _root?: N | null;
56
- get root(): N | null | undefined;
87
+ protected _root?: NODE | null;
88
+ /**
89
+ * The function returns the root node, which can be of type NODE, null, or undefined.
90
+ * @returns The method is returning the value of the `_root` property, which can be of type `NODE`,
91
+ * `null`, or `undefined`.
92
+ */
93
+ get root(): NODE | null | undefined;
57
94
  protected _size: number;
95
+ /**
96
+ * The function returns the size of an object.
97
+ * @returns The size of the object, which is a number.
98
+ */
58
99
  get size(): number;
59
100
  /**
60
101
  * Creates a new instance of BinaryTreeNode with the given key and value.
61
102
  * @param {K} key - The key for the new node.
62
103
  * @param {V} value - The value for the new node.
63
- * @returns {N} - The newly created BinaryTreeNode.
104
+ * @returns {NODE} - The newly created BinaryTreeNode.
64
105
  */
65
- createNode(key: K, value?: V): N;
106
+ createNode(key: K, value?: V): NODE;
66
107
  /**
67
108
  * The function creates a binary tree with the given options.
68
109
  * @param [options] - The `options` parameter is an optional object that allows you to customize the
@@ -72,14 +113,14 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
72
113
  */
73
114
  createTree(options?: Partial<BinaryTreeOptions<K>>): TREE;
74
115
  /**
75
- * The function `exemplarToNode` converts an keyOrNodeOrEntry object into a node object.
76
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, N>`.
116
+ * The function `keyValueOrEntryToNode` converts an keyOrNodeOrEntry object into a node object.
117
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`.
77
118
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
78
- * `exemplarToNode` function. It represents the value associated with the keyOrNodeOrEntry node. If no value
119
+ * `keyValueOrEntryToNode` function. It represents the value associated with the keyOrNodeOrEntry node. If no value
79
120
  * is provided, it will be `undefined`.
80
- * @returns a value of type N (node), or null, or undefined.
121
+ * @returns a value of type NODE (node), or null, or undefined.
81
122
  */
82
- exemplarToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, value?: V): N | null | undefined;
123
+ keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | null | undefined;
83
124
  /**
84
125
  * Time Complexity: O(n)
85
126
  * Space Complexity: O(log n)
@@ -90,7 +131,7 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
90
131
  *
91
132
  * The function `ensureNode` returns the node corresponding to the given key if it is a valid node
92
133
  * key, otherwise it returns the key itself.
93
- * @param {K | N | null | undefined} keyOrNodeOrEntry - The `key` parameter can be of type `K`, `N`,
134
+ * @param {K | NODE | null | undefined} keyOrNodeOrEntry - The `key` parameter can be of type `K`, `NODE`,
94
135
  * `null`, or `undefined`. It represents a key used to identify a node in a binary tree.
95
136
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
96
137
  * type of iteration to be used when searching for a node by key. It has a default value of
@@ -98,74 +139,70 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
98
139
  * @returns either the node corresponding to the given key if it is a valid node key, or the key
99
140
  * itself if it is not a valid node key.
100
141
  */
101
- ensureNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N | null | undefined;
142
+ ensureNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined;
102
143
  /**
103
144
  * The function "isNode" checks if an keyOrNodeOrEntry is an instance of the BinaryTreeNode class.
104
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is a variable of type `KeyOrNodeOrEntry<K, V,N>`.
105
- * @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the class N.
145
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is a variable of type `KeyOrNodeOrEntry<K, V,NODE>`.
146
+ * @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the class NODE.
106
147
  */
107
- isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>): keyOrNodeOrEntry is N;
148
+ isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE;
108
149
  /**
109
150
  * The function checks if a given value is an entry in a binary tree node.
110
- * @param keyOrNodeOrEntry - KeyOrNodeOrEntry<K, V,N> - A generic type representing a node in a binary tree. It has
111
- * two type parameters V and N, representing the value and node type respectively.
151
+ * @param keyOrNodeOrEntry - KeyOrNodeOrEntry<K, V,NODE> - A generic type representing a node in a binary tree. It has
152
+ * two type parameters V and NODE, representing the value and node type respectively.
112
153
  * @returns a boolean value.
113
154
  */
114
- isEntry(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>): keyOrNodeOrEntry is BTNEntry<K, V>;
115
- /**
116
- * Time complexity: O(n)
117
- * Space complexity: O(log n)
118
- */
155
+ isEntry(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is BTNEntry<K, V>;
119
156
  /**
120
157
  * The function checks if a given node is a real node by verifying if it is an instance of
121
158
  * BinaryTreeNode and its key is not NaN.
122
159
  * @param {any} node - The parameter `node` is of type `any`, which means it can be any data type.
123
160
  * @returns a boolean value.
124
161
  */
125
- isRealNode(node: KeyOrNodeOrEntry<K, V, N>): node is N;
162
+ isRealNode(node: KeyOrNodeOrEntry<K, V, NODE>): node is NODE;
126
163
  /**
127
164
  * The function checks if a given node is a BinaryTreeNode instance and has a key value of NaN.
128
165
  * @param {any} node - The parameter `node` is of type `any`, which means it can be any data type.
129
166
  * @returns a boolean value.
130
167
  */
131
- isNIL(node: KeyOrNodeOrEntry<K, V, N>): boolean;
168
+ isNIL(node: KeyOrNodeOrEntry<K, V, NODE>): boolean;
132
169
  /**
133
170
  * The function checks if a given node is a real node or null.
134
171
  * @param {any} node - The parameter `node` is of type `any`, which means it can be any data type.
135
172
  * @returns a boolean value.
136
173
  */
137
- isNodeOrNull(node: KeyOrNodeOrEntry<K, V, N>): node is N | null;
174
+ isNodeOrNull(node: KeyOrNodeOrEntry<K, V, NODE>): node is NODE | null;
138
175
  /**
139
- * Time Complexity O(log n) - O(n)
176
+ * Time Complexity O(n)
140
177
  * Space Complexity O(1)
141
178
  */
142
179
  /**
143
- * Time Complexity O(log n) - O(n)
180
+ * Time Complexity O(n)
144
181
  * Space Complexity O(1)
145
182
  *
146
183
  * The `add` function adds a new node to a binary tree, either by creating a new node or replacing an
147
184
  * existing node with the same key.
148
185
  * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
149
186
  * @param {V} [value] - The value to be inserted into the binary tree.
150
- * @returns The function `add` returns either a node (`N`), `null`, or `undefined`.
187
+ * @returns The function `add` returns either a node (`NODE`), `null`, or `undefined`.
151
188
  */
152
- add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, value?: V): boolean;
189
+ add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
153
190
  /**
154
- * Time Complexity: O(k log n) - O(k * n)
191
+ * Time Complexity: O(k * n)
155
192
  * Space Complexity: O(1)
156
193
  * Comments: The time complexity for adding a node depends on the depth of the tree. In the best case (when the tree is empty), it's O(1). In the worst case (when the tree is a degenerate tree), it's O(n). The space complexity is constant.
157
194
  */
158
195
  /**
159
- * Time Complexity: O(k log n) - O(k * n)
196
+ * Time Complexity: O(k * n)
160
197
  * Space Complexity: O(1)
161
198
  *
162
199
  * The `addMany` function takes in a collection of keysOrNodesOrEntries and an optional collection of values, and
163
200
  * adds each node with its corresponding value to the data structure.
164
201
  * @param keysOrNodesOrEntries - An iterable collection of KeyOrNodeOrEntry objects.
165
202
  * @param [values] - An optional iterable of values that will be assigned to each node being added.
166
- * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
203
+ * @returns The function `addMany` returns an array of `NODE`, `null`, or `undefined` values.
167
204
  */
168
- addMany(keysOrNodesOrEntries: Iterable<KeyOrNodeOrEntry<K, V, N>>, values?: Iterable<V | undefined>): boolean[];
205
+ addMany(keysOrNodesOrEntries: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
169
206
  /**
170
207
  * Time Complexity: O(k * n)
171
208
  * Space Complexity: O(1)
@@ -177,81 +214,73 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
177
214
  *
178
215
  * The `refill` function clears the current data and adds new key-value pairs to the data structure.
179
216
  * @param keysOrNodesOrEntries - An iterable containing keys, nodes, or entries. These can be of type
180
- * KeyOrNodeOrEntry<K, V, N>.
217
+ * KeyOrNodeOrEntry<K, V, NODE>.
181
218
  * @param [values] - The `values` parameter is an optional iterable that contains the values to be
182
219
  * associated with the keys or nodes or entries in the `keysOrNodesOrEntries` parameter. If provided,
183
220
  * the values will be associated with the corresponding keys or nodes or entries in the
184
221
  * `keysOrNodesOrEntries` iterable
185
222
  */
186
- refill(keysOrNodesOrEntries: Iterable<KeyOrNodeOrEntry<K, V, N>>, values?: Iterable<V | undefined>): void;
187
- /**
188
- * Time Complexity: O(k * n)
189
- * Space Complexity: O(1)
190
- * "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.
191
- */
192
- delete<C extends BTNCallback<N, K>>(identifier: K, callback?: C): BinaryTreeDeleteResult<N>[];
193
- delete<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C): BinaryTreeDeleteResult<N>[];
194
- delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C): BinaryTreeDeleteResult<N>[];
223
+ refill(keysOrNodesOrEntries: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): void;
224
+ delete<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C): BinaryTreeDeleteResult<NODE>[];
225
+ delete<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C): BinaryTreeDeleteResult<NODE>[];
226
+ delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C): BinaryTreeDeleteResult<NODE>[];
227
+ getNodes<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, onlyOne?: boolean, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[];
228
+ getNodes<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C, onlyOne?: boolean, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[];
229
+ getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C, onlyOne?: boolean, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[];
230
+ getNode<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined;
231
+ getNode<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined;
232
+ getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined;
195
233
  /**
196
234
  * Time Complexity: O(n)
197
- * Space Complexity: O(1)
235
+ * Space Complexity: O(log n)
198
236
  */
199
237
  /**
200
238
  * Time Complexity: O(n)
201
- * Space Complexity: O(1)
239
+ * Space Complexity: O(log n)
202
240
  *
203
- * The function calculates the depth of a given node in a binary tree.
204
- * @param {K | N | null | undefined} dist - The `dist` parameter represents the node in
205
- * the binary tree whose depth we want to find. It can be of type `K`, `N`, `null`, or
206
- * `undefined`.
207
- * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
208
- * from which we want to calculate the depth. It can be either a `K` (binary tree node key) or
209
- * `N` (binary tree node) or `null` or `undefined`. If no value is provided for `beginRoot
210
- * @returns the depth of the `dist` relative to the `beginRoot`.
241
+ * The function `getNodeByKey` searches for a node in a binary tree by its key, using either
242
+ * recursive or iterative iteration.
243
+ * @param {K} key - The `key` parameter is the key value that we are searching for in the tree.
244
+ * It is used to find the node with the matching key value.
245
+ * @param iterationType - The `iterationType` parameter is used to determine whether the search for
246
+ * the node with the given key should be performed iteratively or recursively. It has two possible
247
+ * values:
248
+ * @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is
249
+ * found in the binary tree. If no node is found, it returns `undefined`.
211
250
  */
212
- getDepth(dist: KeyOrNodeOrEntry<K, V, N>, beginRoot?: KeyOrNodeOrEntry<K, V, N>): number;
251
+ getNodeByKey(key: K, iterationType?: IterationType): NODE | undefined;
252
+ get<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined;
253
+ get<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined;
254
+ get<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined;
255
+ has<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean;
256
+ has<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean;
257
+ has<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean;
213
258
  /**
214
- * Time Complexity: O(n)
259
+ * Time Complexity: O(1)
215
260
  * Space Complexity: O(1)
216
261
  */
217
262
  /**
218
- * Time Complexity: O(n)
219
- * Space Complexity: O(log n)
263
+ * Time Complexity: O(1)
264
+ * Space Complexity: O(1)
220
265
  *
221
- * The function `getHeight` calculates the maximum height of a binary tree using either recursive or
222
- * iterative traversal.
223
- * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
224
- * starting node of the binary tree from which we want to calculate the height. It can be of type
225
- * `K`, `N`, `null`, or `undefined`. If not provided, it defaults to `this.root`.
226
- * @param iterationType - The `iterationType` parameter is used to determine whether to calculate the
227
- * height of the tree using a recursive approach or an iterative approach. It can have two possible
228
- * values:
229
- * @returns the height of the binary tree.
266
+ * Clear the binary tree, removing all nodes.
230
267
  */
231
- getHeight(beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): number;
268
+ clear(): void;
232
269
  /**
233
- * Time Complexity: O(n)
234
- * Space Complexity: O(log n)
235
- * Best Case - O(log n) (when using recursive iterationType), Worst Case - O(n) (when using iterative iterationType)
270
+ * Time Complexity: O(1)
271
+ * Space Complexity: O(1)
236
272
  */
237
273
  /**
238
- * Time Complexity: O(n)
239
- * Space Complexity: O(log n)
274
+ * Time Complexity: O(1)
275
+ * Space Complexity: O(1)
240
276
  *
241
- * The `getMinHeight` function calculates the minimum height of a binary tree using either a
242
- * recursive or iterative approach.
243
- * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
244
- * starting node of the binary tree from which we want to calculate the minimum height. It can be of
245
- * type `K`, `N`, `null`, or `undefined`. If no value is provided, it defaults to `this.root`.
246
- * @param iterationType - The `iterationType` parameter is used to determine the method of iteration
247
- * to calculate the minimum height of a binary tree. It can have two possible values:
248
- * @returns The function `getMinHeight` returns the minimum height of a binary tree.
277
+ * Check if the binary tree is empty.
278
+ * @returns {boolean} - True if the binary tree is empty, false otherwise.
249
279
  */
250
- getMinHeight(beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): number;
280
+ isEmpty(): boolean;
251
281
  /**
252
282
  * Time Complexity: O(n)
253
283
  * Space Complexity: O(log n)
254
- * Best Case - O(log n) (when using recursive iterationType), Worst Case - O(n) (when using iterative iterationType)
255
284
  */
256
285
  /**
257
286
  * Time Complexity: O(n)
@@ -259,93 +288,104 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
259
288
  *
260
289
  * The function checks if a binary tree is perfectly balanced by comparing the minimum height and the
261
290
  * height of the tree.
262
- * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
291
+ * @param {K | NODE | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
263
292
  * for calculating the height and minimum height of a binary tree. It can be either a `K` (a key
264
- * value of a binary tree node), `N` (a node of a binary tree), `null`, or `undefined`. If
293
+ * value of a binary tree node), `NODE` (a node of a binary tree), `null`, or `undefined`. If
265
294
  * @returns a boolean value.
266
295
  */
267
- isPerfectlyBalanced(beginRoot?: KeyOrNodeOrEntry<K, V, N>): boolean;
268
- /**
269
- * Time Complexity: O(n)
270
- * Space Complexity: O(log n)
271
- */
272
- getNodes<C extends BTNCallback<N, K>>(identifier: K, callback?: C, onlyOne?: boolean, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N[];
273
- getNodes<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, onlyOne?: boolean, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N[];
274
- getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, onlyOne?: boolean, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N[];
296
+ isPerfectlyBalanced(beginRoot?: KeyOrNodeOrEntry<K, V, NODE>): boolean;
275
297
  /**
276
298
  * Time Complexity: O(n)
277
- * Space Complexity: O(log n).
299
+ * Space Complexity: O(1)
278
300
  */
279
- has<C extends BTNCallback<N, K>>(identifier: K, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): boolean;
280
- has<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): boolean;
281
- has<C extends BTNCallback<N>>(identifier: ReturnType<C> | null | undefined, callback: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): boolean;
282
301
  /**
283
302
  * Time Complexity: O(n)
284
- * Space Complexity: O(log n).
303
+ * Space Complexity: O(1)
304
+ *
305
+ * The function `isSubtreeBST` checks if a given binary tree is a valid binary search tree.
306
+ * @param {K | NODE | null | undefined} beginRoot - The `beginRoot` parameter represents the root
307
+ * node of the binary search tree (BST) that you want to check if it is a subtree of another BST.
308
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
309
+ * type of iteration to use when checking if a subtree is a binary search tree (BST). It can have two
310
+ * possible values:
311
+ * @returns a boolean value.
285
312
  */
286
- getNode<C extends BTNCallback<N, K>>(identifier: K, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N | null | undefined;
287
- getNode<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N | null | undefined;
288
- getNode<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N | null | undefined;
313
+ isBST(beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean;
289
314
  /**
290
315
  * Time Complexity: O(n)
291
- * Space Complexity: O(log n)
316
+ * Space Complexity: O(1)
292
317
  */
293
318
  /**
294
319
  * Time Complexity: O(n)
295
- * Space Complexity: O(log n)
320
+ * Space Complexity: O(1)
296
321
  *
297
- * The function `getNodeByKey` searches for a node in a binary tree by its key, using either
298
- * recursive or iterative iteration.
299
- * @param {K} key - The `key` parameter is the key value that we are searching for in the tree.
300
- * It is used to find the node with the matching key value.
301
- * @param iterationType - The `iterationType` parameter is used to determine whether the search for
302
- * the node with the given key should be performed iteratively or recursively. It has two possible
303
- * values:
304
- * @returns The function `getNodeByKey` returns a node (`N`) if a node with the specified key is
305
- * found in the binary tree. If no node is found, it returns `undefined`.
322
+ * The function calculates the depth of a given node in a binary tree.
323
+ * @param {K | NODE | null | undefined} dist - The `dist` parameter represents the node in
324
+ * the binary tree whose depth we want to find. It can be of type `K`, `NODE`, `null`, or
325
+ * `undefined`.
326
+ * @param {K | NODE | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
327
+ * from which we want to calculate the depth. It can be either a `K` (binary tree node key) or
328
+ * `NODE` (binary tree node) or `null` or `undefined`. If no value is provided for `beginRoot
329
+ * @returns the depth of the `dist` relative to the `beginRoot`.
306
330
  */
307
- getNodeByKey(key: K, iterationType?: IterationType): N | undefined;
308
- get<C extends BTNCallback<N, K>>(identifier: K, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): V | undefined;
309
- get<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): V | undefined;
310
- get<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): V | undefined;
331
+ getDepth(dist: KeyOrNodeOrEntry<K, V, NODE>, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>): number;
311
332
  /**
312
- * Time Complexity: O(1)
333
+ * Time Complexity: O(n)
313
334
  * Space Complexity: O(1)
314
335
  */
315
336
  /**
316
- * Time Complexity: O(1)
317
- * Space Complexity: O(1)
337
+ * Time Complexity: O(n)
338
+ * Space Complexity: O(log n)
318
339
  *
319
- * Clear the binary tree, removing all nodes.
340
+ * The function `getHeight` calculates the maximum height of a binary tree using either recursive or
341
+ * iterative traversal.
342
+ * @param {K | NODE | null | undefined} beginRoot - The `beginRoot` parameter represents the
343
+ * starting node of the binary tree from which we want to calculate the height. It can be of type
344
+ * `K`, `NODE`, `null`, or `undefined`. If not provided, it defaults to `this.root`.
345
+ * @param iterationType - The `iterationType` parameter is used to determine whether to calculate the
346
+ * height of the tree using a recursive approach or an iterative approach. It can have two possible
347
+ * values:
348
+ * @returns the height of the binary tree.
320
349
  */
321
- clear(): void;
350
+ getHeight(beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): number;
322
351
  /**
323
- * Time Complexity: O(1)
324
- * Space Complexity: O(1)
352
+ * Time Complexity: O(n)
353
+ * Space Complexity: O(log n)
325
354
  */
326
355
  /**
327
- * Time Complexity: O(1)
328
- * Space Complexity: O(1)
356
+ * Time Complexity: O(n)
357
+ * Space Complexity: O(log n)
329
358
  *
330
- * Check if the binary tree is empty.
331
- * @returns {boolean} - True if the binary tree is empty, false otherwise.
359
+ * The `getMinHeight` function calculates the minimum height of a binary tree using either a
360
+ * recursive or iterative approach.
361
+ * @param {K | NODE | null | undefined} beginRoot - The `beginRoot` parameter represents the
362
+ * starting node of the binary tree from which we want to calculate the minimum height. It can be of
363
+ * type `K`, `NODE`, `null`, or `undefined`. If no value is provided, it defaults to `this.root`.
364
+ * @param iterationType - The `iterationType` parameter is used to determine the method of iteration
365
+ * to calculate the minimum height of a binary tree. It can have two possible values:
366
+ * @returns The function `getMinHeight` returns the minimum height of a binary tree.
332
367
  */
333
- isEmpty(): boolean;
368
+ getMinHeight(beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): number;
334
369
  /**
370
+ * Time Complexity: O(log n)
371
+ * Space Complexity: O(log n)
372
+ * /
373
+
374
+ /**
335
375
  * Time Complexity: O(log n)
336
376
  * Space Complexity: O(log n)
337
377
  *
338
378
  * The function `getPathToRoot` returns an array of nodes from a given node to the root of a tree
339
379
  * structure, with the option to reverse the order of the nodes.
340
- * @param {K | N | null | undefined} beginNode - The `beginRoot` parameter represents the
341
- * starting node from which you want to find the path to the root. It can be of type `K`, `N`,
380
+ * @param {K | NODE | null | undefined} beginNode - The `beginRoot` parameter represents the
381
+ * starting node from which you want to find the path to the root. It can be of type `K`, `NODE`,
342
382
  * `null`, or `undefined`.
343
383
  * @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the
344
384
  * resulting path should be reversed or not. If `isReverse` is set to `true`, the path will be
345
385
  * reversed before returning it. If `isReverse` is set to `false`, the path will be returned as is
346
- * @returns The function `getPathToRoot` returns an array of nodes (`N[]`).
386
+ * @returns The function `getPathToRoot` returns an array of nodes (`NODE[]`).
347
387
  */
348
- getPathToRoot(beginNode: KeyOrNodeOrEntry<K, V, N>, isReverse?: boolean): N[];
388
+ getPathToRoot(beginNode: KeyOrNodeOrEntry<K, V, NODE>, isReverse?: boolean): NODE[];
349
389
  /**
350
390
  * Time Complexity: O(log n)
351
391
  * Space Complexity: O(1)
@@ -356,15 +396,15 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
356
396
  *
357
397
  * The function `getLeftMost` returns the leftmost node in a binary tree, either recursively or
358
398
  * iteratively.
359
- * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
360
- * for finding the leftmost node in a binary tree. It can be either a `K` (a key value), `N` (a
399
+ * @param {K | NODE | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
400
+ * for finding the leftmost node in a binary tree. It can be either a `K` (a key value), `NODE` (a
361
401
  * node), `null`, or `undefined`. If not provided, it defaults to `this.root`,
362
402
  * @param iterationType - The `iterationType` parameter is used to determine the type of iteration to
363
403
  * be performed when finding the leftmost node in a binary tree. It can have two possible values:
364
- * @returns The function `getLeftMost` returns the leftmost node (`N`) in the binary tree. If there
404
+ * @returns The function `getLeftMost` returns the leftmost node (`NODE`) in the binary tree. If there
365
405
  * is no leftmost node, it returns `null` or `undefined` depending on the input.
366
406
  */
367
- getLeftMost(beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N | null | undefined;
407
+ getLeftMost(beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined;
368
408
  /**
369
409
  * Time Complexity: O(log n)
370
410
  * Space Complexity: O(1)
@@ -375,47 +415,30 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
375
415
  *
376
416
  * The function `getRightMost` returns the rightmost node in a binary tree, either recursively or
377
417
  * iteratively.
378
- * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
379
- * starting node from which we want to find the rightmost node. It can be of type `K`, `N`,
418
+ * @param {K | NODE | null | undefined} beginRoot - The `beginRoot` parameter represents the
419
+ * starting node from which we want to find the rightmost node. It can be of type `K`, `NODE`,
380
420
  * `null`, or `undefined`. If not provided, it defaults to `this.root`, which is a property of the
381
421
  * current object.
382
422
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
383
423
  * type of iteration to use when finding the rightmost node. It can have one of two values:
384
- * @returns The function `getRightMost` returns the rightmost node (`N`) in a binary tree. If there
424
+ * @returns The function `getRightMost` returns the rightmost node (`NODE`) in a binary tree. If there
385
425
  * is no rightmost node, it returns `null` or `undefined`, depending on the input.
386
426
  */
387
- getRightMost(beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N | null | undefined;
427
+ getRightMost(beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined;
388
428
  /**
389
429
  * Time Complexity: O(log n)
390
430
  * Space Complexity: O(1)
391
431
  */
392
432
  /**
393
- * Time Complexity: O(n)
433
+ * Time Complexity: O(log n)
394
434
  * Space Complexity: O(1)
395
435
  *
396
- * The function `isSubtreeBST` checks if a given binary tree is a valid binary search tree.
397
- * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the root
398
- * node of the binary search tree (BST) that you want to check if it is a subtree of another BST.
399
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
400
- * type of iteration to use when checking if a subtree is a binary search tree (BST). It can have two
401
- * possible values:
402
- * @returns a boolean value.
403
- */
404
- isBST(beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): boolean;
405
- dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
406
- dfs<C extends BTNCallback<N | null>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
407
- /**
408
- * Time complexity: O(n)
409
- * Space complexity: O(n)
410
- */
411
- bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
412
- bfs<C extends BTNCallback<N | null>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
413
- /**
414
- * Time complexity: O(n)
415
- * Space complexity: O(n)
436
+ * The function returns the predecessor of a given node in a tree.
437
+ * @param {NODE} node - The parameter `node` is of type `RedBlackTreeNode`, which represents a node in a
438
+ * tree.
439
+ * @returns the predecessor of the given 'node'.
416
440
  */
417
- listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
418
- listLevels<C extends BTNCallback<N | null>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
441
+ getPredecessor(node: NODE): NODE;
419
442
  /**
420
443
  * Time Complexity: O(log n)
421
444
  * Space Complexity: O(1)
@@ -424,19 +447,18 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
424
447
  * Time Complexity: O(log n)
425
448
  * Space Complexity: O(1)
426
449
  *
427
- * The function returns the predecessor of a given node in a tree.
428
- * @param {N} node - The parameter `node` is of type `RedBlackTreeNode`, which represents a node in a
429
- * tree.
430
- * @returns the predecessor of the given 'node'.
431
- */
432
- getPredecessor(node: N): N;
433
- /**
434
450
  * The function `getSuccessor` returns the next node in a binary tree given a current node.
435
- * @param {K | N | null} [x] - The parameter `x` can be of type `K`, `N`, or `null`.
451
+ * @param {K | NODE | null} [x] - The parameter `x` can be of type `K`, `NODE`, or `null`.
436
452
  * @returns the successor of the given node or key. The successor is the node that comes immediately
437
453
  * after the given node in the inorder traversal of the binary tree.
438
454
  */
439
- getSuccessor(x?: K | N | null): N | null | undefined;
455
+ getSuccessor(x?: K | NODE | null): NODE | null | undefined;
456
+ dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
457
+ dfs<C extends BTNCallback<NODE | null>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
458
+ bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
459
+ bfs<C extends BTNCallback<NODE | null>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
460
+ listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
461
+ listLevels<C extends BTNCallback<NODE | null>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
440
462
  /**
441
463
  * Time complexity: O(n)
442
464
  * Space complexity: O(n)
@@ -448,19 +470,19 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
448
470
  * The `morris` function performs a depth-first traversal on a binary tree using the Morris traversal
449
471
  * algorithm.
450
472
  * @param {C} callback - The `callback` parameter is a function that will be called for each node in
451
- * the tree. It takes a single parameter of type `N` (the type of the nodes in the tree) and returns
473
+ * the tree. It takes a single parameter of type `NODE` (the type of the nodes in the tree) and returns
452
474
  * a value of any type.
453
475
  * @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter in the `morris` function
454
476
  * determines the order in which the nodes of a binary tree are traversed. It can have one of the
455
477
  * following values:
456
- * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
478
+ * @param {K | NODE | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
457
479
  * for the traversal. It can be specified as a key, a node object, or `null`/`undefined` to indicate
458
480
  * the root of the tree. If no value is provided, the default value is the root of the tree.
459
481
  * @returns The function `morris` returns an array of values that are the result of invoking the
460
482
  * `callback` function on each node in the binary tree. The type of the array nodes is determined
461
483
  * by the return type of the `callback` function.
462
484
  */
463
- morris<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, N>): ReturnType<C>[];
485
+ morris<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>): ReturnType<C>[];
464
486
  /**
465
487
  * Time complexity: O(n)
466
488
  * Space complexity: O(n)
@@ -523,36 +545,59 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
523
545
  * Space Complexity: O(n)
524
546
  *
525
547
  * The `print` function is used to display a binary tree structure in a visually appealing way.
526
- * @param {K | N | null | undefined} [beginRoot=this.root] - The `root` parameter is of type `K | N | null |
548
+ * @param {K | NODE | null | undefined} [beginRoot=this.root] - The `root` parameter is of type `K | NODE | null |
527
549
  * undefined`. It represents the root node of a binary tree. The root node can have one of the
528
550
  * following types:
529
551
  * @param {BinaryTreePrintOptions} [options={ isShowUndefined: false, isShowNull: false, isShowRedBlackNIL: false}] - Options object that controls printing behavior. You can specify whether to display undefined, null, or sentinel nodes.
530
552
  */
531
- print(beginRoot?: KeyOrNodeOrEntry<K, V, N>, options?: BinaryTreePrintOptions): void;
532
- protected _getIterator(node?: N | null | undefined): IterableIterator<[K, V | undefined]>;
533
- protected _displayAux(node: N | null | undefined, options: BinaryTreePrintOptions): NodeDisplayLayout;
534
- protected _defaultOneParamCallback: (node: N | null | undefined) => K | undefined;
553
+ print(beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, options?: BinaryTreePrintOptions): void;
554
+ /**
555
+ * The function `_getIterator` is a protected generator function that returns an iterator for the
556
+ * key-value pairs in a binary search tree.
557
+ * @param node - The `node` parameter represents the current node in the binary search tree. It is an
558
+ * optional parameter with a default value of `this.root`, which means if no node is provided, the
559
+ * root node of the tree will be used as the starting point for iteration.
560
+ * @returns The function `_getIterator` returns an `IterableIterator` of key-value pairs `[K, V |
561
+ * undefined]`.
562
+ */
563
+ protected _getIterator(node?: NODE | null | undefined): IterableIterator<[K, V | undefined]>;
564
+ /**
565
+ * The `_displayAux` function is responsible for generating the display layout of a binary tree node,
566
+ * taking into account various options such as whether to show null, undefined, or NaN nodes.
567
+ * @param {NODE | null | undefined} node - The `node` parameter represents a node in a binary tree.
568
+ * It can be of type `NODE`, `null`, or `undefined`.
569
+ * @param {BinaryTreePrintOptions} options - The `options` parameter is an object that contains the
570
+ * following properties:
571
+ * @returns The function `_displayAux` returns a `NodeDisplayLayout` which is an array containing the
572
+ * following elements:
573
+ * 1. `mergedLines`: An array of strings representing the lines of the node display.
574
+ * 2. `totalWidth`: The total width of the node display.
575
+ * 3. `totalHeight`: The total height of the node display.
576
+ * 4. `middleIndex`: The index of the middle character
577
+ */
578
+ protected _displayAux(node: NODE | null | undefined, options: BinaryTreePrintOptions): NodeDisplayLayout;
579
+ protected _defaultOneParamCallback: (node: NODE | null | undefined) => K | undefined;
535
580
  /**
536
581
  * Swap the data of two nodes in the binary tree.
537
- * @param {N} srcNode - The source node to swap.
538
- * @param {N} destNode - The destination node to swap.
539
- * @returns {N} - The destination node after the swap.
582
+ * @param {NODE} srcNode - The source node to swap.
583
+ * @param {NODE} destNode - The destination node to swap.
584
+ * @returns {NODE} - The destination node after the swap.
540
585
  */
541
- protected _swapProperties(srcNode: KeyOrNodeOrEntry<K, V, N>, destNode: KeyOrNodeOrEntry<K, V, N>): N | undefined;
586
+ protected _swapProperties(srcNode: KeyOrNodeOrEntry<K, V, NODE>, destNode: KeyOrNodeOrEntry<K, V, NODE>): NODE | undefined;
542
587
  /**
543
588
  * The function replaces an old node with a new node in a binary tree.
544
- * @param {N} oldNode - The oldNode parameter represents the node that needs to be replaced in the
589
+ * @param {NODE} oldNode - The oldNode parameter represents the node that needs to be replaced in the
545
590
  * tree.
546
- * @param {N} newNode - The `newNode` parameter is the node that will replace the `oldNode` in the
591
+ * @param {NODE} newNode - The `newNode` parameter is the node that will replace the `oldNode` in the
547
592
  * tree.
548
593
  * @returns The method is returning the newNode.
549
594
  */
550
- protected _replaceNode(oldNode: N, newNode: N): N;
595
+ protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
551
596
  /**
552
597
  * The function sets the root property of an object to a given value, and if the value is not null,
553
598
  * it also sets the parent property of the value to undefined.
554
- * @param {N | null | undefined} v - The parameter `v` is of type `N | null | undefined`, which means it can either be of
555
- * type `N` or `null`.
599
+ * @param {NODE | null | undefined} v - The parameter `v` is of type `NODE | null | undefined`, which means it can either be of
600
+ * type `NODE` or `null`.
556
601
  */
557
- protected _setRoot(v: N | null | undefined): void;
602
+ protected _setRoot(v: NODE | null | undefined): void;
558
603
  }