min-heap-typed 1.42.8 → 1.43.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 (49) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +88 -23
  2. package/dist/data-structures/binary-tree/avl-tree.js +88 -23
  3. package/dist/data-structures/binary-tree/binary-tree.d.ts +180 -74
  4. package/dist/data-structures/binary-tree/binary-tree.js +415 -236
  5. package/dist/data-structures/binary-tree/bst.d.ts +121 -66
  6. package/dist/data-structures/binary-tree/bst.js +121 -67
  7. package/dist/data-structures/binary-tree/rb-tree.d.ts +72 -5
  8. package/dist/data-structures/binary-tree/rb-tree.js +95 -18
  9. package/dist/data-structures/binary-tree/tree-multimap.d.ts +82 -43
  10. package/dist/data-structures/binary-tree/tree-multimap.js +82 -43
  11. package/dist/data-structures/graph/abstract-graph.d.ts +139 -36
  12. package/dist/data-structures/graph/abstract-graph.js +147 -36
  13. package/dist/data-structures/graph/directed-graph.d.ts +126 -0
  14. package/dist/data-structures/graph/directed-graph.js +126 -0
  15. package/dist/data-structures/graph/undirected-graph.d.ts +63 -0
  16. package/dist/data-structures/graph/undirected-graph.js +63 -0
  17. package/dist/data-structures/heap/heap.d.ts +175 -12
  18. package/dist/data-structures/heap/heap.js +175 -12
  19. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +203 -0
  20. package/dist/data-structures/linked-list/doubly-linked-list.js +203 -0
  21. package/dist/data-structures/linked-list/singly-linked-list.d.ts +182 -0
  22. package/dist/data-structures/linked-list/singly-linked-list.js +182 -0
  23. package/dist/data-structures/linked-list/skip-linked-list.d.ts +64 -0
  24. package/dist/data-structures/linked-list/skip-linked-list.js +64 -0
  25. package/dist/data-structures/queue/deque.d.ts +113 -3
  26. package/dist/data-structures/queue/deque.js +113 -3
  27. package/dist/data-structures/queue/queue.d.ts +87 -0
  28. package/dist/data-structures/queue/queue.js +87 -0
  29. package/dist/data-structures/stack/stack.d.ts +42 -0
  30. package/dist/data-structures/stack/stack.js +42 -0
  31. package/dist/data-structures/trie/trie.d.ts +76 -0
  32. package/dist/data-structures/trie/trie.js +76 -1
  33. package/package.json +2 -2
  34. package/src/data-structures/binary-tree/avl-tree.ts +97 -23
  35. package/src/data-structures/binary-tree/binary-tree.ts +465 -256
  36. package/src/data-structures/binary-tree/bst.ts +130 -68
  37. package/src/data-structures/binary-tree/rb-tree.ts +106 -19
  38. package/src/data-structures/binary-tree/tree-multimap.ts +88 -44
  39. package/src/data-structures/graph/abstract-graph.ts +133 -7
  40. package/src/data-structures/graph/directed-graph.ts +145 -1
  41. package/src/data-structures/graph/undirected-graph.ts +72 -0
  42. package/src/data-structures/heap/heap.ts +201 -12
  43. package/src/data-structures/linked-list/doubly-linked-list.ts +232 -0
  44. package/src/data-structures/linked-list/singly-linked-list.ts +208 -0
  45. package/src/data-structures/linked-list/skip-linked-list.ts +74 -0
  46. package/src/data-structures/queue/deque.ts +127 -3
  47. package/src/data-structures/queue/queue.ts +99 -0
  48. package/src/data-structures/stack/stack.ts +48 -0
  49. package/src/data-structures/trie/trie.ts +87 -4
@@ -87,24 +87,51 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
87
87
  */
88
88
  createNode(key: BTNKey, value?: V): N;
89
89
  /**
90
- * Add a node with the given key and value to the binary tree.
91
- * @param {BTNKey | N | null} keyOrNode - The key or node to add to the binary tree.
92
- * @param {V} value - The value for the new node (optional).
93
- * @returns {N | null | undefined} - The inserted node, or null if nothing was inserted, or undefined if the operation failed.
90
+ * Time Complexity: O(n)
91
+ * Space Complexity: O(1)
92
+ * 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.
93
+ */
94
+ /**
95
+ * Time Complexity: O(n)
96
+ * Space Complexity: O(1)
97
+ *
98
+ * The `add` function adds a new node with a key and value to a binary tree, or updates the value of
99
+ * an existing node with the same key.
100
+ * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
101
+ * following types:
102
+ * @param {V} [value] - The value to be associated with the key or node being added to the binary
103
+ * tree.
104
+ * @returns The function `add` returns a node (`N`) if it was successfully inserted into the binary
105
+ * tree, or `null` or `undefined` if the insertion was not successful.
94
106
  */
95
107
  add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | null | undefined;
96
108
  /**
97
- * The `addMany` function takes an array of binary tree node IDs or nodes, and optionally an array of corresponding data
98
- * values, and adds them to the binary tree.
99
- * @param {(BTNKey | null)[] | (N | null)[]} keysOrNodes - An array of BTNKey or BinaryTreeNode
100
- * objects, or null values.
101
- * @param {V[]} [values] - The `values` parameter is an optional array of values (`V[]`) that corresponds to
102
- * the nodes or node IDs being added. It is used to set the value of each node being added. If `values` is not provided,
103
- * the value of the nodes will be `undefined`.
109
+ * Time Complexity: O(k * n) "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.
110
+ * Space Complexity: O(1)
111
+ */
112
+ /**
113
+ * Time Complexity: O(k * n) "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.
114
+ * Space Complexity: O(1)
115
+ *
116
+ * The `addMany` function takes an array of keys or nodes and an optional array of values, and adds
117
+ * each key-value pair to a data structure.
118
+ * @param {(BTNKey | N |null | undefined)[]} keysOrNodes - An array of keys or nodes to be added to
119
+ * the binary search tree. Each element can be of type `BTNKey` (a key value), `N` (a node), `null`,
120
+ * or `undefined`.
121
+ * @param {(V | undefined)[]} [values] - The `values` parameter is an optional array of values that
122
+ * correspond to the keys or nodes being added. If provided, the values will be associated with the
123
+ * keys or nodes during the add operation.
104
124
  * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
105
125
  */
106
126
  addMany(keysOrNodes: (BTNKey | N | null | undefined)[], values?: (V | undefined)[]): (N | null | undefined)[];
107
127
  /**
128
+ * Time Complexity: O(k * n) "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.
129
+ * Space Complexity: O(1)
130
+ */
131
+ /**
132
+ * Time Complexity: O(k * n) "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.
133
+ * Space Complexity: O(1)
134
+ *
108
135
  * The `refill` function clears the binary tree and adds multiple nodes with the given IDs or nodes and optional data.
109
136
  * @param {(BTNKey | N)[]} keysOrNodes - The `keysOrNodes` parameter is an array that can contain either
110
137
  * `BTNKey` or `N` values.
@@ -118,48 +145,76 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
118
145
  delete<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C): BiTreeDeleteResult<N>[];
119
146
  delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C): BiTreeDeleteResult<N>[];
120
147
  /**
121
- * The function `getDepth` calculates the depth of a given node in a binary tree relative to a
122
- * specified root node.
123
- * @param {BTNKey | N | null | undefined} distNode - The `distNode` parameter represents the node
124
- * whose depth we want to find in the binary tree. It can be either a node object (`N`), a key value
125
- * of the node (`BTNKey`), or `null`.
126
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
127
- * starting node from which we want to calculate the depth. It can be either a node object or the key
128
- * of a node in the binary tree. If no value is provided for `beginRoot`, it defaults to the root
129
- * node of the binary tree.
148
+ * Time Complexity: O(n)
149
+ * Space Complexity: O(1)
150
+ */
151
+ /**
152
+ * Time Complexity: O(n)
153
+ * Space Complexity: O(1)
154
+ *
155
+ * The function calculates the depth of a given node in a binary tree.
156
+ * @param {BTNKey | N | null | undefined} distNode - The `distNode` parameter represents the node in
157
+ * the binary tree whose depth we want to find. It can be of type `BTNKey`, `N`, `null`, or
158
+ * `undefined`.
159
+ * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
160
+ * from which we want to calculate the depth. It can be either a `BTNKey` (binary tree node key) or
161
+ * `N` (binary tree node) or `null` or `undefined`. If no value is provided for `beginRoot
130
162
  * @returns the depth of the `distNode` relative to the `beginRoot`.
131
163
  */
132
164
  getDepth(distNode: BTNKey | N | null | undefined, beginRoot?: BTNKey | N | null | undefined): number;
133
165
  /**
134
- * The `getHeight` function calculates the maximum height of a binary tree using either recursive or
135
- * iterative approach.
166
+ * Time Complexity: O(n)
167
+ * Space Complexity: O(log n)
168
+ * Best Case - O(log n) (when using recursive iterationType), Worst Case - O(n) (when using iterative iterationType)
169
+ */
170
+ /**
171
+ * Time Complexity: O(n)
172
+ * Space Complexity: O(log n)
173
+ *
174
+ * The function `getHeight` calculates the maximum height of a binary tree using either recursive or
175
+ * iterative traversal.
136
176
  * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
137
- * starting node from which the height of the binary tree is calculated. It can be either a node
138
- * object (`N`), a key value of a node in the tree (`BTNKey`), or `null` if no starting
139
- * node is specified. If `
177
+ * starting node of the binary tree from which we want to calculate the height. It can be of type
178
+ * `BTNKey`, `N`, `null`, or `undefined`. If not provided, it defaults to `this.root`.
140
179
  * @param iterationType - The `iterationType` parameter is used to determine whether to calculate the
141
- * height of the binary tree using a recursive approach or an iterative approach. It can have two
142
- * possible values:
180
+ * height of the tree using a recursive approach or an iterative approach. It can have two possible
181
+ * values:
143
182
  * @returns the height of the binary tree.
144
183
  */
145
184
  getHeight(beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): number;
146
185
  /**
186
+ * Time Complexity: O(n)
187
+ * Space Complexity: O(log n)
188
+ * Best Case - O(log n) (when using recursive iterationType), Worst Case - O(n) (when using iterative iterationType)
189
+ */
190
+ /**
191
+ * Time Complexity: O(n)
192
+ * Space Complexity: O(log n)
193
+ *
147
194
  * The `getMinHeight` function calculates the minimum height of a binary tree using either a
148
195
  * recursive or iterative approach.
149
- * @param {N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node from which we want to
150
- * calculate the minimum height of the tree. It is optional and defaults to the root of the tree if
151
- * not provided.
196
+ * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
197
+ * starting node of the binary tree from which we want to calculate the minimum height. It can be of
198
+ * type `BTNKey`, `N`, `null`, or `undefined`. If no value is provided, it defaults to `this.root`.
152
199
  * @param iterationType - The `iterationType` parameter is used to determine the method of iteration
153
200
  * to calculate the minimum height of a binary tree. It can have two possible values:
154
201
  * @returns The function `getMinHeight` returns the minimum height of a binary tree.
155
202
  */
156
203
  getMinHeight(beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): number;
157
204
  /**
205
+ * Time Complexity: O(n)
206
+ * Space Complexity: O(log n)
207
+ */
208
+ /**
209
+ * Time Complexity: O(n)
210
+ * Space Complexity: O(log n)
211
+ *
158
212
  * The function checks if a binary tree is perfectly balanced by comparing the minimum height and the
159
213
  * height of the tree.
160
- * @param {N | null | undefined} beginRoot - The parameter `beginRoot` is of type `N | null | undefined`, which means it can
161
- * either be of type `N` (representing a node in a tree) or `null` (representing an empty tree).
162
- * @returns The method is returning a boolean value.
214
+ * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
215
+ * for calculating the height and minimum height of a binary tree. It can be either a `BTNKey` (a key
216
+ * value of a binary tree node), `N` (a node of a binary tree), `null`, or `undefined`. If
217
+ * @returns a boolean value.
163
218
  */
164
219
  isPerfectlyBalanced(beginRoot?: BTNKey | N | null | undefined): boolean;
165
220
  getNodes<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, onlyOne?: boolean, beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): N[];
@@ -172,6 +227,13 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
172
227
  getNode<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): N | null | undefined;
173
228
  getNode<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): N | null | undefined;
174
229
  /**
230
+ * Time Complexity: O(n)
231
+ * Space Complexity: O(log n)
232
+ */
233
+ /**
234
+ * Time Complexity: O(n)
235
+ * Space Complexity: O(log n)
236
+ *
175
237
  * The function `getNodeByKey` searches for a node in a binary tree by its key, using either
176
238
  * recursive or iterative iteration.
177
239
  * @param {BTNKey} key - The `key` parameter is the key value that we are searching for in the tree.
@@ -208,56 +270,93 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
208
270
  */
209
271
  isEmpty(): boolean;
210
272
  /**
211
- * The function `getPathToRoot` returns an array of nodes starting from a given node and traversing
212
- * up to the root node, with the option to reverse the order of the nodes.
213
- * @param {N} beginRoot - The `beginRoot` parameter represents the starting node from which you want
214
- * to find the path to the root node.
273
+ * Time Complexity: O(log n)
274
+ * Space Complexity: O(log n)
275
+ */
276
+ /**
277
+ * Time Complexity: O(log n)
278
+ * Space Complexity: O(log n)
279
+ *
280
+ * The function `getPathToRoot` returns an array of nodes from a given node to the root of a tree
281
+ * structure, with the option to reverse the order of the nodes.
282
+ * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
283
+ * starting node from which you want to find the path to the root. It can be of type `BTNKey`, `N`,
284
+ * `null`, or `undefined`.
215
285
  * @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the
216
286
  * resulting path should be reversed or not. If `isReverse` is set to `true`, the path will be
217
- * reversed before returning it. If `isReverse` is set to `false` or not provided, the path will
218
- * @returns The function `getPathToRoot` returns an array of type `N[]`.
287
+ * reversed before returning it. If `isReverse` is set to `false`, the path will be returned as is
288
+ * @returns The function `getPathToRoot` returns an array of nodes (`N[]`).
219
289
  */
220
290
  getPathToRoot(beginRoot: BTNKey | N | null | undefined, isReverse?: boolean): N[];
221
291
  /**
222
- * The function `getLeftMost` returns the leftmost node in a binary tree, either using recursive or
223
- * iterative traversal.
292
+ * Time Complexity: O(log n)
293
+ * Space Complexity: O(1)
294
+ */
295
+ /**
296
+ * Time Complexity: O(log n)
297
+ * Space Complexity: O(1)
298
+ *
299
+ * The function `getLeftMost` returns the leftmost node in a binary tree, either recursively or
300
+ * iteratively.
224
301
  * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
225
- * for finding the leftmost node in a binary tree. It can be either a node object (`N`), a key value
226
- * of a node (`BTNKey`), or `null` if the tree is empty.
302
+ * for finding the leftmost node in a binary tree. It can be either a `BTNKey` (a key value), `N` (a
303
+ * node), `null`, or `undefined`. If not provided, it defaults to `this.root`,
227
304
  * @param iterationType - The `iterationType` parameter is used to determine the type of iteration to
228
305
  * be performed when finding the leftmost node in a binary tree. It can have two possible values:
229
- * @returns The function `getLeftMost` returns the leftmost node (`N`) in a binary tree. If there is
230
- * no leftmost node, it returns `null`.
306
+ * @returns The function `getLeftMost` returns the leftmost node (`N`) in the binary tree. If there
307
+ * is no leftmost node, it returns `null` or `undefined` depending on the input.
231
308
  */
232
309
  getLeftMost(beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): N | null | undefined;
233
310
  /**
311
+ * Time Complexity: O(log n)
312
+ * Space Complexity: O(1)
313
+ */
314
+ /**
315
+ * Time Complexity: O(log n)
316
+ * Space Complexity: O(1)
317
+ *
234
318
  * The function `getRightMost` returns the rightmost node in a binary tree, either recursively or
235
319
  * iteratively.
236
- * @param {N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node from which we want to
237
- * find the rightmost node. It is of type `N | null | undefined`, which means it can either be a node of type `N`
238
- * or `null`. If it is `null`, it means there is no starting node
239
- * @param iterationType - The `iterationType` parameter is used to determine the type of iteration to
240
- * be performed when finding the rightmost node in a binary tree. It can have two possible values:
241
- * @returns The function `getRightMost` returns the rightmost node (`N`) in a binary tree. If the
242
- * `beginRoot` parameter is `null`, it returns `null`.
320
+ * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
321
+ * starting node from which we want to find the rightmost node. It can be of type `BTNKey`, `N`,
322
+ * `null`, or `undefined`. If not provided, it defaults to `this.root`, which is a property of the
323
+ * current object.
324
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
325
+ * type of iteration to use when finding the rightmost node. It can have one of two values:
326
+ * @returns The function `getRightMost` returns the rightmost node (`N`) in a binary tree. If there
327
+ * is no rightmost node, it returns `null` or `undefined`, depending on the input.
243
328
  */
244
329
  getRightMost(beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): N | null | undefined;
245
330
  /**
331
+ * Time Complexity: O(n)
332
+ * Space Complexity: O(1)
333
+ */
334
+ /**
335
+ * Time Complexity: O(n)
336
+ * Space Complexity: O(1)
337
+ *
246
338
  * The function `isSubtreeBST` checks if a given binary tree is a valid binary search tree.
247
- * @param {N} beginRoot - The `beginRoot` parameter is the root node of the binary tree that you want
248
- * to check if it is a binary search tree (BST) subtree.
339
+ * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the root
340
+ * node of the binary search tree (BST) that you want to check if it is a subtree of another BST.
249
341
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
250
342
  * type of iteration to use when checking if a subtree is a binary search tree (BST). It can have two
251
343
  * possible values:
252
- * @returns The function `isSubtreeBST` returns a boolean value.
344
+ * @returns a boolean value.
253
345
  */
254
346
  isSubtreeBST(beginRoot: BTNKey | N | null | undefined, iterationType?: IterationType): boolean;
255
347
  /**
348
+ * Time Complexity: O(n)
349
+ * Space Complexity: O(1)
350
+ */
351
+ /**
352
+ * Time Complexity: O(n)
353
+ * Space Complexity: O(1)
354
+ *
256
355
  * The function checks if a binary tree is a binary search tree.
257
356
  * @param iterationType - The parameter "iterationType" is used to specify the type of iteration to
258
357
  * be used when checking if the binary tree is a binary search tree (BST). It is an optional
259
- * parameter with a default value of "this.iterationType". The value of "this.iterationType" is not
260
- * provided in
358
+ * parameter with a default value of "this.iterationType". The value of "this.iterationType" is
359
+ * expected to be
261
360
  * @returns a boolean value.
262
361
  */
263
362
  isBST(iterationType?: IterationType): boolean;
@@ -301,26 +400,33 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
301
400
  listLevels<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
302
401
  getPredecessor(node: N): N;
303
402
  /**
304
- * The function `getSuccessor` returns the next node in a binary tree given a node `x`, or `null` if
305
- * `x` is the last node.
306
- * @param {N} x - N - a node in a binary tree
307
- * @returns The function `getSuccessor` returns a value of type `N` (the successor node), or `null`
308
- * if there is no successor, or `undefined` if the input `x` is `undefined`.
403
+ * The function `getSuccessor` returns the next node in a binary tree given a current node.
404
+ * @param {BTNKey | N | null} [x] - The parameter `x` can be of type `BTNKey`, `N`, or `null`.
405
+ * @returns the successor of the given node or key. The successor is the node that comes immediately
406
+ * after the given node in the inorder traversal of the binary tree.
309
407
  */
310
408
  getSuccessor(x?: BTNKey | N | null): N | null | undefined;
311
409
  /**
312
- * The `morris` function performs a depth-first traversal of a binary tree using the Morris traversal
313
- * algorithm and returns an array of values obtained by applying a callback function to each node.
314
- * @param callback - The `callback` parameter is a function that will be called on each node in the
315
- * tree. It takes a node of type `N` as input and returns a value of type `ReturnType<BTNCallback<N>>`. The
316
- * default value for this parameter is `this._defaultOneParamCallback`.
410
+ * Time complexity: O(n)
411
+ * Space complexity: O(1)
412
+ */
413
+ /**
414
+ * Time complexity: O(n)
415
+ * Space complexity: O(1)
416
+ * The `morris` function performs a depth-first traversal on a binary tree using the Morris traversal
417
+ * algorithm.
418
+ * @param {C} callback - The `callback` parameter is a function that will be called for each node in
419
+ * the tree. It takes a single parameter of type `N` (the type of the nodes in the tree) and returns
420
+ * a value of any type.
317
421
  * @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter in the `morris` function
318
422
  * determines the order in which the nodes of a binary tree are traversed. It can have one of the
319
423
  * following values:
320
- * @param {N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node for the Morris
321
- * traversal. It specifies the root node of the tree from which the traversal should begin. If
322
- * `beginRoot` is `null`, an empty array will be returned.
323
- * @returns The `morris` function returns an array of `ReturnType<BTNCallback<N>>` values.
424
+ * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
425
+ * for the traversal. It can be specified as a key, a node object, or `null`/`undefined` to indicate
426
+ * the root of the tree. If no value is provided, the default value is the root of the tree.
427
+ * @returns The function `morris` returns an array of values that are the result of invoking the
428
+ * `callback` function on each node in the binary tree. The type of the array elements is determined
429
+ * by the return type of the `callback` function.
324
430
  */
325
431
  morris<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNKey | N | null | undefined): ReturnType<C>[];
326
432
  /**
@@ -362,9 +468,9 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
362
468
  protected _setRoot(v: N | null | undefined): void;
363
469
  /**
364
470
  * The `print` function is used to display a binary tree structure in a visually appealing way.
365
- * @param {N | null | undefined} root - The `root` parameter in the `print` function represents the
366
- * root node of a binary tree. It can have one of the following types: `BTNKey`, `N`, `null`, or
367
- * `undefined`. The default value is `this.root`, which suggests that `this.root` is the
471
+ * @param {N | null | undefined} root - The `root` parameter is of type `BTNKey | N | null |
472
+ * undefined`. It represents the root node of a binary tree. The root node can have one of the
473
+ * following types:
368
474
  */
369
475
  print(beginRoot?: BTNKey | N | null | undefined): void;
370
476
  }