data-structure-typed 1.34.7 → 1.34.9

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 (167) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +1 -1
  3. package/CONTRIBUTING.md +0 -0
  4. package/README.md +8 -8
  5. package/dist/data-structures/binary-tree/aa-tree.js +2 -5
  6. package/dist/data-structures/binary-tree/aa-tree.js.map +1 -1
  7. package/dist/data-structures/binary-tree/abstract-binary-tree.js +314 -457
  8. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
  9. package/dist/data-structures/binary-tree/avl-tree.js +64 -90
  10. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  11. package/dist/data-structures/binary-tree/b-tree.js +2 -5
  12. package/dist/data-structures/binary-tree/b-tree.js.map +1 -1
  13. package/dist/data-structures/binary-tree/binary-indexed-tree.js +17 -22
  14. package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  15. package/dist/data-structures/binary-tree/binary-tree.js +12 -31
  16. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
  17. package/dist/data-structures/binary-tree/bst.js +157 -244
  18. package/dist/data-structures/binary-tree/bst.js.map +1 -1
  19. package/dist/data-structures/binary-tree/rb-tree.js +20 -44
  20. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
  21. package/dist/data-structures/binary-tree/segment-tree.js +80 -122
  22. package/dist/data-structures/binary-tree/segment-tree.js.map +1 -1
  23. package/dist/data-structures/binary-tree/splay-tree.js +2 -5
  24. package/dist/data-structures/binary-tree/splay-tree.js.map +1 -1
  25. package/dist/data-structures/binary-tree/tree-multiset.js +168 -239
  26. package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
  27. package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
  28. package/dist/data-structures/binary-tree/two-three-tree.js.map +1 -1
  29. package/dist/data-structures/graph/abstract-graph.js +351 -585
  30. package/dist/data-structures/graph/abstract-graph.js.map +1 -1
  31. package/dist/data-structures/graph/directed-graph.js +152 -282
  32. package/dist/data-structures/graph/directed-graph.js.map +1 -1
  33. package/dist/data-structures/graph/map-graph.js +47 -88
  34. package/dist/data-structures/graph/map-graph.js.map +1 -1
  35. package/dist/data-structures/graph/undirected-graph.js +91 -180
  36. package/dist/data-structures/graph/undirected-graph.js.map +1 -1
  37. package/dist/data-structures/hash/coordinate-map.js +23 -45
  38. package/dist/data-structures/hash/coordinate-map.js.map +1 -1
  39. package/dist/data-structures/hash/coordinate-set.js +20 -42
  40. package/dist/data-structures/hash/coordinate-set.js.map +1 -1
  41. package/dist/data-structures/hash/hash-map.js +85 -247
  42. package/dist/data-structures/hash/hash-map.js.map +1 -1
  43. package/dist/data-structures/hash/hash-table.js +87 -128
  44. package/dist/data-structures/hash/hash-table.js.map +1 -1
  45. package/dist/data-structures/hash/pair.js +2 -5
  46. package/dist/data-structures/hash/pair.js.map +1 -1
  47. package/dist/data-structures/hash/tree-map.js +2 -5
  48. package/dist/data-structures/hash/tree-map.js.map +1 -1
  49. package/dist/data-structures/hash/tree-set.js +2 -5
  50. package/dist/data-structures/hash/tree-set.js.map +1 -1
  51. package/dist/data-structures/heap/heap.js +56 -80
  52. package/dist/data-structures/heap/heap.js.map +1 -1
  53. package/dist/data-structures/heap/max-heap.js +8 -26
  54. package/dist/data-structures/heap/max-heap.js.map +1 -1
  55. package/dist/data-structures/heap/min-heap.js +8 -26
  56. package/dist/data-structures/heap/min-heap.js.map +1 -1
  57. package/dist/data-structures/linked-list/doubly-linked-list.js +149 -218
  58. package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  59. package/dist/data-structures/linked-list/singly-linked-list.js +119 -218
  60. package/dist/data-structures/linked-list/singly-linked-list.js.map +1 -1
  61. package/dist/data-structures/linked-list/skip-linked-list.js +50 -70
  62. package/dist/data-structures/linked-list/skip-linked-list.js.map +1 -1
  63. package/dist/data-structures/matrix/matrix.js +7 -8
  64. package/dist/data-structures/matrix/matrix.js.map +1 -1
  65. package/dist/data-structures/matrix/matrix2d.js +57 -70
  66. package/dist/data-structures/matrix/matrix2d.js.map +1 -1
  67. package/dist/data-structures/matrix/navigator.js +18 -37
  68. package/dist/data-structures/matrix/navigator.js.map +1 -1
  69. package/dist/data-structures/matrix/vector2d.js +63 -84
  70. package/dist/data-structures/matrix/vector2d.js.map +1 -1
  71. package/dist/data-structures/priority-queue/max-priority-queue.js +13 -41
  72. package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  73. package/dist/data-structures/priority-queue/min-priority-queue.js +13 -41
  74. package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  75. package/dist/data-structures/priority-queue/priority-queue.js +93 -139
  76. package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
  77. package/dist/data-structures/queue/deque.js +82 -128
  78. package/dist/data-structures/queue/deque.js.map +1 -1
  79. package/dist/data-structures/queue/queue.js +57 -157
  80. package/dist/data-structures/queue/queue.js.map +1 -1
  81. package/dist/data-structures/stack/stack.js +21 -22
  82. package/dist/data-structures/stack/stack.js.map +1 -1
  83. package/dist/data-structures/tree/tree.js +33 -46
  84. package/dist/data-structures/tree/tree.js.map +1 -1
  85. package/dist/data-structures/trie/trie.js +93 -200
  86. package/dist/data-structures/trie/trie.js.map +1 -1
  87. package/dist/types/data-structures/abstract-binary-tree.js.map +1 -1
  88. package/dist/utils/utils.js +22 -107
  89. package/dist/utils/utils.js.map +1 -1
  90. package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +124 -123
  91. package/lib/data-structures/binary-tree/abstract-binary-tree.js +136 -216
  92. package/lib/data-structures/binary-tree/avl-tree.d.ts +19 -10
  93. package/lib/data-structures/binary-tree/avl-tree.js +35 -13
  94. package/lib/data-structures/binary-tree/binary-tree.d.ts +6 -6
  95. package/lib/data-structures/binary-tree/binary-tree.js +7 -7
  96. package/lib/data-structures/binary-tree/bst.d.ts +34 -34
  97. package/lib/data-structures/binary-tree/bst.js +86 -89
  98. package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
  99. package/lib/data-structures/binary-tree/rb-tree.js +4 -4
  100. package/lib/data-structures/binary-tree/tree-multiset.d.ts +40 -42
  101. package/lib/data-structures/binary-tree/tree-multiset.js +76 -86
  102. package/lib/data-structures/graph/abstract-graph.d.ts +62 -62
  103. package/lib/data-structures/graph/abstract-graph.js +86 -86
  104. package/lib/data-structures/graph/directed-graph.d.ts +51 -51
  105. package/lib/data-structures/graph/directed-graph.js +63 -63
  106. package/lib/data-structures/graph/map-graph.d.ts +13 -13
  107. package/lib/data-structures/graph/map-graph.js +12 -12
  108. package/lib/data-structures/graph/undirected-graph.d.ts +30 -30
  109. package/lib/data-structures/graph/undirected-graph.js +32 -32
  110. package/lib/data-structures/priority-queue/priority-queue.d.ts +3 -3
  111. package/lib/data-structures/priority-queue/priority-queue.js +3 -3
  112. package/lib/data-structures/tree/tree.d.ts +4 -4
  113. package/lib/data-structures/tree/tree.js +6 -6
  114. package/lib/interfaces/abstract-binary-tree.d.ts +37 -42
  115. package/lib/interfaces/abstract-graph.d.ts +13 -13
  116. package/lib/interfaces/avl-tree.d.ts +6 -4
  117. package/lib/interfaces/bst.d.ts +10 -9
  118. package/lib/interfaces/directed-graph.d.ts +5 -5
  119. package/lib/interfaces/rb-tree.d.ts +2 -2
  120. package/lib/interfaces/undirected-graph.d.ts +2 -2
  121. package/lib/types/data-structures/abstract-binary-tree.d.ts +3 -3
  122. package/lib/types/data-structures/abstract-binary-tree.js +0 -1
  123. package/lib/types/data-structures/abstract-graph.d.ts +2 -2
  124. package/lib/types/data-structures/bst.d.ts +2 -2
  125. package/lib/types/data-structures/tree-multiset.d.ts +1 -1
  126. package/lib/types/utils/validate-type.d.ts +8 -8
  127. package/package.json +6 -6
  128. package/scripts/rename_clear_files.sh +29 -0
  129. package/src/data-structures/binary-tree/abstract-binary-tree.ts +241 -293
  130. package/src/data-structures/binary-tree/avl-tree.ts +43 -14
  131. package/src/data-structures/binary-tree/binary-tree.ts +8 -8
  132. package/src/data-structures/binary-tree/bst.ts +101 -96
  133. package/src/data-structures/binary-tree/rb-tree.ts +9 -9
  134. package/src/data-structures/binary-tree/tree-multiset.ts +82 -94
  135. package/src/data-structures/graph/abstract-graph.ts +114 -109
  136. package/src/data-structures/graph/directed-graph.ts +77 -77
  137. package/src/data-structures/graph/map-graph.ts +20 -15
  138. package/src/data-structures/graph/undirected-graph.ts +39 -39
  139. package/src/data-structures/priority-queue/priority-queue.ts +3 -3
  140. package/src/data-structures/tree/tree.ts +7 -7
  141. package/src/interfaces/abstract-binary-tree.ts +37 -50
  142. package/src/interfaces/abstract-graph.ts +13 -13
  143. package/src/interfaces/avl-tree.ts +6 -4
  144. package/src/interfaces/bst.ts +9 -9
  145. package/src/interfaces/directed-graph.ts +5 -5
  146. package/src/interfaces/rb-tree.ts +2 -2
  147. package/src/interfaces/undirected-graph.ts +2 -2
  148. package/src/types/data-structures/abstract-binary-tree.ts +3 -4
  149. package/src/types/data-structures/abstract-graph.ts +2 -2
  150. package/src/types/data-structures/bst.ts +2 -2
  151. package/src/types/data-structures/tree-multiset.ts +1 -1
  152. package/src/types/utils/validate-type.ts +10 -10
  153. package/test/integration/avl-tree.test.ts +24 -24
  154. package/test/integration/bst.test.ts +71 -71
  155. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +28 -28
  156. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +4 -12
  157. package/test/unit/data-structures/binary-tree/bst.test.ts +79 -79
  158. package/test/unit/data-structures/binary-tree/overall.test.ts +20 -20
  159. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +80 -80
  160. package/test/unit/data-structures/graph/directed-graph.test.ts +8 -8
  161. package/test/unit/data-structures/graph/map-graph.test.ts +4 -4
  162. package/test/unit/data-structures/graph/overall.test.ts +2 -2
  163. package/test/unit/data-structures/graph/undirected-graph.test.ts +1 -1
  164. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +4 -5
  165. package/test/unit/data-structures/tree/tree.test.ts +2 -2
  166. package/umd/bundle.min.js +1 -1
  167. package/umd/bundle.min.js.map +1 -1
@@ -5,36 +5,27 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { AbstractBinaryTreeNodeNested, AbstractBinaryTreeNodeProperties, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName } from '../../types';
8
+ import type { AbstractBinaryTreeNodeNested, AbstractBinaryTreeNodeProperties, BinaryTreeDeletedResult, BinaryTreeNodeKey, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName } from '../../types';
9
9
  import { AbstractBinaryTreeOptions, FamilyPosition, LoopType } from '../../types';
10
10
  import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from '../../interfaces';
11
11
  export declare abstract class AbstractBinaryTreeNode<V = any, NEIGHBOR extends AbstractBinaryTreeNode<V, NEIGHBOR> = AbstractBinaryTreeNodeNested<V>> implements IAbstractBinaryTreeNode<V, NEIGHBOR> {
12
12
  /**
13
- * The constructor function initializes a BinaryTreeNode object with an id and an optional value.
14
- * @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
13
+ * The constructor function initializes a BinaryTreeNode object with a key and an optional value.
14
+ * @param {BinaryTreeNodeKey} key - The `key` parameter is of type `BinaryTreeNodeKey` and represents the unique identifier
15
15
  * of the binary tree node. It is used to distinguish one node from another in the binary tree.
16
16
  * @param {V} [val] - The "val" parameter is an optional parameter of type V. It represents the value that will be
17
17
  * stored in the binary tree node. If no value is provided, it will be set to undefined.
18
18
  */
19
- protected constructor(id: BinaryTreeNodeId, val?: V);
20
- private _id;
21
- get id(): BinaryTreeNodeId;
22
- set id(v: BinaryTreeNodeId);
23
- private _val;
24
- get val(): V | undefined;
25
- set val(value: V | undefined);
19
+ protected constructor(key: BinaryTreeNodeKey, val?: V);
20
+ key: BinaryTreeNodeKey;
21
+ val: V | undefined;
26
22
  private _left;
27
23
  get left(): NEIGHBOR | null | undefined;
28
24
  set left(v: NEIGHBOR | null | undefined);
29
25
  private _right;
30
26
  get right(): NEIGHBOR | null | undefined;
31
27
  set right(v: NEIGHBOR | null | undefined);
32
- private _parent;
33
- get parent(): NEIGHBOR | null | undefined;
34
- set parent(v: NEIGHBOR | null | undefined);
35
- private _height;
36
- get height(): number;
37
- set height(v: number);
28
+ parent: NEIGHBOR | null | undefined;
38
29
  /**
39
30
  * The function determines the position of a node in a family tree structure.
40
31
  * @returns a value of type `FamilyPosition`.
@@ -54,13 +45,10 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
54
45
  get size(): number;
55
46
  private _loopType;
56
47
  get loopType(): LoopType;
57
- private _visitedId;
58
- get visitedId(): BinaryTreeNodeId[];
59
- private _visitedVal;
60
- get visitedVal(): N['val'][];
61
- private _visitedNode;
62
- get visitedNode(): N[];
63
- abstract createNode(id: BinaryTreeNodeId, val?: N['val']): N | null;
48
+ visitedKey: BinaryTreeNodeKey[];
49
+ visitedVal: N['val'][];
50
+ visitedNode: N[];
51
+ abstract createNode(key: BinaryTreeNodeKey, val?: N['val']): N | null;
64
52
  /**
65
53
  * The `swapLocation` function swaps the location of two nodes in a binary tree.
66
54
  * @param {N} srcNode - The source node that you want to swap with the destination node.
@@ -70,7 +58,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
70
58
  */
71
59
  swapLocation(srcNode: N, destNode: N): N;
72
60
  /**
73
- * The clear() function resets the root, size, and maxId properties to their initial values.
61
+ * The clear() function resets the root, size, and maxKey properties to their initial values.
74
62
  */
75
63
  clear(): void;
76
64
  /**
@@ -84,57 +72,57 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
84
72
  */
85
73
  /**
86
74
  * The `add` function adds a new node to a binary tree, either by ID or by creating a new node with a given value.
87
- * @param {BinaryTreeNodeId | N | null} idOrNode - The `idOrNode` parameter can be either a `BinaryTreeNodeId`, which
75
+ * @param {BinaryTreeNodeKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a `BinaryTreeNodeKey`, which
88
76
  * is a number representing the ID of a binary tree node, or it can be a `N` object, which represents a binary tree
89
77
  * node itself. It can also be `null` if no node is specified.
90
78
  * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the new node
91
79
  * being added to the binary tree.
92
80
  * @returns The function `add` returns either the inserted node (`N`), `null`, or `undefined`.
93
81
  */
94
- add(idOrNode: BinaryTreeNodeId | N | null, val?: N['val']): N | null | undefined;
82
+ add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val']): N | null | undefined;
95
83
  /**
96
84
  * The `addMany` function takes an array of binary tree node IDs or nodes, and optionally an array of corresponding data
97
85
  * values, and adds them to the binary tree.
98
- * @param {(BinaryTreeNodeId | null)[] | (N | null)[]} idsOrNodes - An array of BinaryTreeNodeId or BinaryTreeNode
86
+ * @param {(BinaryTreeNodeKey | null)[] | (N | null)[]} keysOrNodes - An array of BinaryTreeNodeKey or BinaryTreeNode
99
87
  * objects, or null values.
100
88
  * @param {N['val'][]} [data] - The `data` parameter is an optional array of values (`N['val'][]`) that corresponds to
101
89
  * the nodes or node IDs being added. It is used to set the value of each node being added. If `data` is not provided,
102
90
  * the value of the nodes will be `undefined`.
103
91
  * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
104
92
  */
105
- addMany(idsOrNodes: (BinaryTreeNodeId | null)[] | (N | null)[], data?: N['val'][]): (N | null | undefined)[];
93
+ addMany(keysOrNodes: (BinaryTreeNodeKey | null)[] | (N | null)[], data?: N['val'][]): (N | null | undefined)[];
106
94
  /**
107
- * The `fill` function clears the binary tree and adds multiple nodes with the given IDs or nodes and optional data.
108
- * @param {(BinaryTreeNodeId | N)[]} idsOrNodes - The `idsOrNodes` parameter is an array that can contain either
109
- * `BinaryTreeNodeId` or `N` values.
95
+ * The `refill` function clears the binary tree and adds multiple nodes with the given IDs or nodes and optional data.
96
+ * @param {(BinaryTreeNodeKey | N)[]} keysOrNodes - The `keysOrNodes` parameter is an array that can contain either
97
+ * `BinaryTreeNodeKey` or `N` values.
110
98
  * @param {N[] | Array<N['val']>} [data] - The `data` parameter is an optional array of values that will be assigned to
111
- * the nodes being added. If provided, the length of the `data` array should be equal to the length of the `idsOrNodes`
99
+ * the nodes being added. If provided, the length of the `data` array should be equal to the length of the `keysOrNodes`
112
100
  * array. Each value in the `data` array will be assigned to the
113
101
  * @returns The method is returning a boolean value.
114
102
  */
115
- fill(idsOrNodes: (BinaryTreeNodeId | null)[] | (N | null)[], data?: N[] | Array<N['val']>): boolean;
103
+ refill(keysOrNodes: (BinaryTreeNodeKey | null)[] | (N | null)[], data?: N[] | Array<N['val']>): boolean;
116
104
  /**
117
105
  * The `remove` function in TypeScript is used to delete a node from a binary search tree and returns an array of objects
118
106
  * containing the deleted node and the node that needs to be balanced.
119
- * @param {N | BinaryTreeNodeId} nodeOrId - The `nodeOrId` parameter can be either a node object (`N`) or a binary tree
120
- * node ID (`BinaryTreeNodeId`).
107
+ * @param {N | BinaryTreeNodeKey} nodeOrKey - The `nodeOrKey` parameter can be either a node object (`N`) or a binary tree
108
+ * node ID (`BinaryTreeNodeKey`).
121
109
  * @returns The function `remove` returns an array of `BinaryTreeDeletedResult<N>` objects.
122
110
  */
123
- remove(nodeOrId: N | BinaryTreeNodeId): BinaryTreeDeletedResult<N>[];
111
+ remove(nodeOrKey: N | BinaryTreeNodeKey): BinaryTreeDeletedResult<N>[];
124
112
  /**
125
113
  * The function calculates the depth of a node in a binary tree.
126
- * @param {N | BinaryTreeNodeId | null} beginRoot - The `beginRoot` parameter can be one of the following:
114
+ * @param {N | BinaryTreeNodeKey | null} beginRoot - The `beginRoot` parameter can be one of the following:
127
115
  * @returns the depth of the given node or binary tree.
128
116
  */
129
- getDepth(beginRoot: N | BinaryTreeNodeId | null): number;
117
+ getDepth(beginRoot?: N | BinaryTreeNodeKey | null): number;
130
118
  /**
131
119
  * The `getHeight` function calculates the maximum height of a binary tree, either recursively or iteratively.
132
- * @param {N | BinaryTreeNodeId | null} [beginRoot] - The `beginRoot` parameter is optional and can be of type `N` (a
133
- * generic type representing a node in a binary tree), `BinaryTreeNodeId` (a type representing the ID of a binary tree
120
+ * @param {N | BinaryTreeNodeKey | null} [beginRoot] - The `beginRoot` parameter is optional and can be of type `N` (a
121
+ * generic type representing a node in a binary tree), `BinaryTreeNodeKey` (a type representing the ID of a binary tree
134
122
  * node), or `null`.
135
123
  * @returns the height of the binary tree.
136
124
  */
137
- getHeight(beginRoot?: N | BinaryTreeNodeId | null): number;
125
+ getHeight(beginRoot?: N | BinaryTreeNodeKey | null): number;
138
126
  /**
139
127
  * The `getMinHeight` function calculates the minimum height of a binary tree using either a recursive or iterative
140
128
  * approach.
@@ -154,37 +142,37 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
154
142
  isPerfectlyBalanced(beginRoot?: N | null): boolean;
155
143
  /**
156
144
  * The function `getNodes` returns an array of nodes that match a given property name and value in a binary tree.
157
- * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
145
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or a
158
146
  * generic type `N`. It represents the property of the binary tree node that you want to search for.
159
147
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
160
- * specifies the property name to use when searching for nodes. If not provided, it defaults to 'id'.
148
+ * specifies the property name to use when searching for nodes. If not provided, it defaults to 'key'.
161
149
  * @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
162
150
  * return only one node that matches the given `nodeProperty` or `propertyName`. If `onlyOne` is set to `true`, the
163
151
  * function will stop traversing the tree and return the first matching node. If `only
164
152
  * @returns an array of nodes (type N).
165
153
  */
166
- getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
154
+ getNodes(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
167
155
  /**
168
156
  * The function checks if a binary tree node has a specific property.
169
- * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or `N`.
157
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or `N`.
170
158
  * It represents the property of the binary tree node that you want to check.
171
159
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
172
- * specifies the name of the property to be checked in the nodes. If not provided, it defaults to 'id'.
160
+ * specifies the name of the property to be checked in the nodes. If not provided, it defaults to 'key'.
173
161
  * @returns a boolean value.
174
162
  */
175
- has(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): boolean;
163
+ has(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): boolean;
176
164
  /**
177
165
  * The function returns the first node that matches the given property name and value, or null if no matching node is
178
166
  * found.
179
- * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or `N`.
167
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or `N`.
180
168
  * It represents the property of the binary tree node that you want to search for.
181
169
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
182
170
  * specifies the property name to be used for searching the binary tree nodes. If this parameter is not provided, the
183
- * default value is set to `'id'`.
171
+ * default value is set to `'key'`.
184
172
  * @returns either the value of the specified property of the node, or the node itself if no property name is provided.
185
173
  * If no matching node is found, it returns null.
186
174
  */
187
- get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
175
+ get(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): N | null;
188
176
  /**
189
177
  * The function `getPathToRoot` returns an array of nodes representing the path from a given node to the root node, with
190
178
  * an option to reverse the order of the nodes.
@@ -199,7 +187,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
199
187
  /**
200
188
  * The function `getLeftMost` returns the leftmost node in a binary tree, starting from a specified node or the root if
201
189
  * no node is specified.
202
- * generic type representing a node in a binary tree), `BinaryTreeNodeId` (a type representing the ID of a binary tree
190
+ * generic type representing a node in a binary tree), `BinaryTreeNodeKey` (a type representing the ID of a binary tree
203
191
  * node), or `null`.
204
192
  * @returns The function `getLeftMost` returns the leftmost node in a binary tree. If the `beginRoot` parameter is
205
193
  * provided, it starts the traversal from that node. If `beginRoot` is not provided or is `null`, it starts the traversal
@@ -210,8 +198,8 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
210
198
  /**
211
199
  * The function `getLeftMost` returns the leftmost node in a binary tree, starting from a specified node or the root if
212
200
  * no node is specified.
213
- * @param {N | BinaryTreeNodeId | null} [node] - The `beginRoot` parameter is optional and can be of type `N` (a
214
- * generic type representing a node in a binary tree), `BinaryTreeNodeId` (a type representing the ID of a binary tree
201
+ * @param {N | BinaryTreeNodeKey | null} [node] - The `beginRoot` parameter is optional and can be of type `N` (a
202
+ * generic type representing a node in a binary tree), `BinaryTreeNodeKey` (a type representing the ID of a binary tree
215
203
  * node).
216
204
  * @returns The function `getLeftMost` returns the leftmost node in a binary tree. If the `beginRoot` parameter is
217
205
  * provided, it starts the traversal from that node. If `beginRoot` is not provided or is `null`, it starts the traversal
@@ -229,13 +217,13 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
229
217
  /**
230
218
  * The `getRightMost` function returns the rightmost node in a binary tree, either recursively or iteratively using tail
231
219
  * recursion optimization.
232
- * @param {N | null} [node] - The `node` parameter is an optional parameter of type `N` or `null`. It represents the
220
+ * @param {N | null} [beginRoot] - The `node` parameter is an optional parameter of type `N` or `null`. It represents the
233
221
  * starting node from which we want to find the rightmost node. If no node is provided, the function will default to
234
222
  * using the root node of the data structure.
235
223
  * @returns The `getRightMost` function returns the rightmost node in a binary tree. It returns the rightmost node
236
224
  * starting from that node.
237
225
  */
238
- getRightMost(node: N): N;
226
+ getRightMost(beginRoot: N): N;
239
227
  /**
240
228
  * The function checks if a binary search tree is valid by traversing it either recursively or iteratively.
241
229
  * @param {N | null} node - The `node` parameter represents the root node of a binary search tree (BST).
@@ -256,154 +244,176 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
256
244
  getSubTreeSize(subTreeRoot: N | null | undefined): number;
257
245
  /**
258
246
  * The function `subTreeSum` calculates the sum of a specified property in a binary tree or subtree.
259
- * @param {N | BinaryTreeNodeId | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
247
+ * @param {N | BinaryTreeNodeKey | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
260
248
  * tree or the ID of a binary tree node. It can also be `null` if there is no subtree.
261
249
  * @param {BinaryTreeNodePropertyName} [propertyName] - propertyName is an optional parameter that specifies the
262
- * property of the binary tree node to use for calculating the sum. It can be either 'id' or 'val'. If propertyName is
263
- * not provided, it defaults to 'id'.
250
+ * property of the binary tree node to use for calculating the sum. It can be either 'key' or 'val'. If propertyName is
251
+ * not provided, it defaults to 'key'.
264
252
  * @returns a number, which is the sum of the values of the specified property in the subtree rooted at `subTreeRoot`.
265
253
  */
266
- subTreeSum(subTreeRoot: N | BinaryTreeNodeId | null, propertyName?: BinaryTreeNodePropertyName): number;
254
+ subTreeSum(subTreeRoot: N | BinaryTreeNodeKey | null, propertyName?: BinaryTreeNodePropertyName): number;
267
255
  /**
268
256
  * The function `subTreeAdd` adds a delta value to a specified property of each node in a subtree.
269
- * @param {N | BinaryTreeNodeId | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
257
+ * @param {N | BinaryTreeNodeKey | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
270
258
  * tree or the ID of a node in the binary tree. It can also be `null` if there is no subtree to add to.
271
259
  * @param {number} delta - The `delta` parameter is a number that represents the amount by which the property value of
272
260
  * each node in the subtree should be incremented.
273
261
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
274
- * specifies the property of the binary tree node that should be modified. If not provided, it defaults to 'id'.
262
+ * specifies the property of the binary tree node that should be modified. If not provided, it defaults to 'key'.
275
263
  * @returns a boolean value.
276
264
  */
277
- subTreeAdd(subTreeRoot: N | BinaryTreeNodeId | null, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
265
+ subTreeAdd(subTreeRoot: N | BinaryTreeNodeKey | null, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
278
266
  /**
279
- * Performs a breadth-first search (BFS) on a binary tree, accumulating properties of each node based on their 'id' property.
267
+ * Performs a breadth-first search (bfs) on a binary tree, accumulating properties of each node based on their 'key' property.
280
268
  * @returns An array of binary tree node IDs.
281
269
  */
282
- BFS(): BinaryTreeNodeId[];
270
+ bfs(): BinaryTreeNodeKey[];
283
271
  /**
284
- * Performs a breadth-first search (BFS) on a binary tree, accumulating properties of each node based on the specified property name.
285
- * @param {'id'} nodeOrPropertyName - The name of the property to accumulate.
272
+ * Performs a breadth-first search (bfs) on a binary tree, accumulating properties of each node based on the specified property name.
273
+ * @param {'key'} nodeOrPropertyName - The name of the property to accumulate.
286
274
  * @returns An array of values corresponding to the specified property.
287
275
  */
288
- BFS(nodeOrPropertyName: 'id'): BinaryTreeNodeId[];
276
+ bfs(nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
289
277
  /**
290
- * Performs a breadth-first search (BFS) on a binary tree, accumulating the 'val' property of each node.
278
+ * Performs a breadth-first search (bfs) on a binary tree, accumulating the 'val' property of each node.
291
279
  * @param {'val'} nodeOrPropertyName - The name of the property to accumulate.
292
280
  * @returns An array of 'val' properties from each node.
293
281
  */
294
- BFS(nodeOrPropertyName: 'val'): N['val'][];
282
+ bfs(nodeOrPropertyName: 'val'): N['val'][];
295
283
  /**
296
- * Performs a breadth-first search (BFS) on a binary tree, accumulating nodes themselves.
284
+ * Performs a breadth-first search (bfs) on a binary tree, accumulating nodes themselves.
297
285
  * @param {'node'} nodeOrPropertyName - The name of the property to accumulate.
298
286
  * @returns An array of binary tree nodes.
299
287
  */
300
- BFS(nodeOrPropertyName: 'node'): N[];
288
+ bfs(nodeOrPropertyName: 'node'): N[];
301
289
  /**
302
- * Performs a depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on their 'id' property.
290
+ * Performs a depth-first search (dfs) traversal on a binary tree and accumulates properties of each node based on their 'key' property.
303
291
  * @returns An array of binary tree node IDs.
304
292
  */
305
- DFS(): BinaryTreeNodeId[];
293
+ dfs(): BinaryTreeNodeKey[];
306
294
  /**
307
- * Performs a depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on the specified property name.
295
+ * Performs a depth-first search (dfs) traversal on a binary tree and accumulates properties of each node based on the specified property name.
296
+ * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
297
+ * @returns An array of values corresponding to the specified property.
298
+ */
299
+ dfs(pattern: DFSOrderPattern): BinaryTreeNodeKey[];
300
+ /**
301
+ * Performs a depth-first search (dfs) traversal on a binary tree and accumulates properties of each node based on the specified property name.
308
302
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
309
303
  * @param {string} nodeOrPropertyName - The name of the property to accumulate.
310
304
  * @returns An array of values corresponding to the specified property.
311
305
  */
312
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
306
+ dfs(pattern: DFSOrderPattern, nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
313
307
  /**
314
- * Performs a depth-first search (DFS) traversal on a binary tree and accumulates the 'val' property of each node.
308
+ * Performs a depth-first search (dfs) traversal on a binary tree and accumulates the 'val' property of each node.
315
309
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
316
310
  * @param {'val'} nodeOrPropertyName - The name of the property to accumulate.
317
311
  * @returns An array of 'val' properties from each node.
318
312
  */
319
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
313
+ dfs(pattern: DFSOrderPattern, nodeOrPropertyName: 'val'): N[];
320
314
  /**
321
- * Performs a depth-first search (DFS) traversal on a binary tree and accumulates nodes themselves.
315
+ * Performs a depth-first search (dfs) traversal on a binary tree and accumulates nodes themselves.
322
316
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
323
317
  * @param {'node'} nodeOrPropertyName - The name of the property to accumulate.
324
318
  * @returns An array of binary tree nodes.
325
319
  */
326
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
320
+ dfs(pattern: DFSOrderPattern, nodeOrPropertyName: 'node'): N[];
327
321
  /**
328
- * Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on their 'id' property.
322
+ * Performs an iterative depth-first search (dfs) traversal on a binary tree and accumulates properties of each node based on their 'key' property.
329
323
  * @returns An array of binary tree node IDs.
330
324
  */
331
- DFSIterative(): BinaryTreeNodeId[];
325
+ dfsIterative(): BinaryTreeNodeKey[];
332
326
  /**
333
- * Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on the specified property name.
327
+ * Performs an iterative depth-first search (dfs) traversal on a binary tree and accumulates properties of each node based on their 'key' property.
328
+ * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
329
+ * @returns An array of values corresponding to the specified property.
330
+ */
331
+ dfsIterative(pattern: DFSOrderPattern): BinaryTreeNodeKey[];
332
+ /**
333
+ * Performs an iterative depth-first search (dfs) traversal on a binary tree and accumulates properties of each node based on the specified property name.
334
334
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
335
335
  * @param {string} nodeOrPropertyName - The name of the property to accumulate.
336
336
  * @returns An array of values corresponding to the specified property.
337
337
  */
338
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
338
+ dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
339
339
  /**
340
- * Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates the 'val' property of each node.
340
+ * Performs an iterative depth-first search (dfs) traversal on a binary tree and accumulates the 'val' property of each node.
341
341
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
342
342
  * @param {'val'} nodeOrPropertyName - The name of the property to accumulate.
343
343
  * @returns An array of 'val' properties from each node.
344
344
  */
345
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
345
+ dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'val'): N['val'][];
346
346
  /**
347
- * Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates nodes themselves.
347
+ * Performs an iterative depth-first search (dfs) traversal on a binary tree and accumulates nodes themselves.
348
348
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
349
349
  * @param {'node'} nodeOrPropertyName - The name of the property to accumulate.
350
350
  * @returns An array of binary tree nodes.
351
351
  */
352
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
352
+ dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'node'): N[];
353
+ /**
354
+ * Performs a level-order traversal on a binary tree starting from the specified node and accumulates properties of each node based on their 'key' property.
355
+ * @returns An array of binary tree node IDs.
356
+ */
357
+ levelIterative(): BinaryTreeNodeKey[];
353
358
  /**
354
- * Performs a level-order traversal on a binary tree starting from the specified node and accumulates properties of each node based on their 'id' property.
359
+ * Performs a level-order traversal on a binary tree starting from the specified node and accumulates properties of each node based on their 'key' property.
355
360
  * @param {N | null} node - The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.
356
361
  * @returns An array of binary tree node IDs.
357
362
  */
358
- levelIterative(node: N | null): BinaryTreeNodeId[];
363
+ levelIterative(node: N | null): BinaryTreeNodeKey[];
359
364
  /**
360
365
  * Performs a level-order traversal on a binary tree starting from the specified node and accumulates properties of each node based on the specified property name.
361
366
  * @param {N | null} node - The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.
362
367
  * @param {string} nodeOrPropertyName - The name of the property to accumulate.
363
368
  * @returns An array of values corresponding to the specified property.
364
369
  */
365
- levelIterative(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
370
+ levelIterative(node: N | null, nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
366
371
  /**
367
372
  * Performs a level-order traversal on a binary tree starting from the specified node and accumulates the 'val' property of each node.
368
373
  * @param {N | null} node - The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.
369
374
  * @param {'val'} nodeOrPropertyName - The name of the property to accumulate.
370
375
  * @returns An array of 'val' properties from each node.
371
376
  */
372
- levelIterative(node: N | null, nodeOrPropertyName?: 'val'): N['val'][];
377
+ levelIterative(node: N | null, nodeOrPropertyName: 'val'): N['val'][];
373
378
  /**
374
379
  * Performs a level-order traversal on a binary tree starting from the specified node and accumulates nodes themselves.
375
380
  * @param {N | null} node - The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.
376
381
  * @param {'node'} nodeOrPropertyName - The name of the property to accumulate.
377
382
  * @returns An array of binary tree nodes.
378
383
  */
379
- levelIterative(node: N | null, nodeOrPropertyName?: 'node'): N[];
384
+ levelIterative(node: N | null, nodeOrPropertyName: 'node'): N[];
385
+ /**
386
+ * Collects nodes from a binary tree by a specified property and organizes them into levels.
387
+ * @returns A 2D array of AbstractBinaryTreeNodeProperty<N> objects.
388
+ */
389
+ listLevels(): BinaryTreeNodeKey[][];
380
390
  /**
381
391
  * Collects nodes from a binary tree by a specified property and organizes them into levels.
382
392
  * @param {N | null} node - The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.
383
393
  * @returns A 2D array of AbstractBinaryTreeNodeProperty<N> objects.
384
394
  */
385
- listLevels(node: N | null): BinaryTreeNodeId[][];
395
+ listLevels(node: N | null): BinaryTreeNodeKey[][];
386
396
  /**
387
397
  * Collects nodes from a binary tree by a specified property and organizes them into levels.
388
398
  * @param {N | null} node - The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.
389
- * @param {'id} nodeOrPropertyName - The property of the BinaryTreeNode object to collect at each level.
399
+ * @param {'key} nodeOrPropertyName - The property of the BinaryTreeNode object to collect at each level.
390
400
  * @returns A 2D array of values corresponding to the specified property.
391
401
  */
392
- listLevels(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[][];
402
+ listLevels(node: N | null, nodeOrPropertyName: 'key'): BinaryTreeNodeKey[][];
393
403
  /**
394
404
  * Collects nodes from a binary tree by a specified property and organizes them into levels.
395
405
  * @param {N | null} node - The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.
396
406
  * @param {'val'} nodeOrPropertyName - The property of the BinaryTreeNode object to collect at each level.
397
407
  * @returns A 2D array of 'val' properties from each node.
398
408
  */
399
- listLevels(node: N | null, nodeOrPropertyName?: 'val'): N['val'][][];
409
+ listLevels(node: N | null, nodeOrPropertyName: 'val'): N['val'][][];
400
410
  /**
401
411
  * Collects nodes from a binary tree by a specified property and organizes them into levels.
402
412
  * @param {N | null} node - The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.
403
413
  * @param {'node'} nodeOrPropertyName - The property of the BinaryTreeNode object to collect at each level.
404
414
  * @returns A 2D array of binary tree nodes.
405
415
  */
406
- listLevels(node: N | null, nodeOrPropertyName?: 'node'): N[][];
416
+ listLevels(node: N | null, nodeOrPropertyName: 'node'): N[][];
407
417
  /**
408
418
  * The function returns the predecessor of a given node in a binary tree.
409
419
  * @param node - The parameter `node` is a BinaryTreeNode object, representing a node in a binary tree.
@@ -412,34 +422,40 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
412
422
  getPredecessor(node: N): N;
413
423
  /**
414
424
  * Time complexity is O(n)
415
- * Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack
425
+ * Space complexity of Iterative dfs equals to recursive dfs which is O(n) because of the stack
416
426
  */
417
427
  /**
418
428
  * Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm.
419
429
  * @returns An array of binary tree node IDs.
420
430
  */
421
- morris(): BinaryTreeNodeId[];
431
+ morris(): BinaryTreeNodeKey[];
432
+ /**
433
+ * Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm and accumulates properties of each node based on the specified property name.
434
+ * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
435
+ * @param {'key'} nodeOrPropertyName - The name of the property to accumulate.
436
+ * @returns An array of values corresponding to the specified property.
437
+ */
438
+ morris(pattern: DFSOrderPattern, nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
422
439
  /**
423
440
  * Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm and accumulates properties of each node based on the specified property name.
424
441
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
425
- * @param {'id'} nodeOrPropertyName - The name of the property to accumulate.
426
442
  * @returns An array of values corresponding to the specified property.
427
443
  */
428
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
444
+ morris(pattern: DFSOrderPattern): BinaryTreeNodeKey[];
429
445
  /**
430
446
  * Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm and accumulates the 'val' property of each node.
431
447
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
432
448
  * @param {'val'} nodeOrPropertyName - The property of the BinaryTreeNode object to collect at each level.
433
449
  * @returns An array of 'val' properties from each node.
434
450
  */
435
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
451
+ morris(pattern: DFSOrderPattern, nodeOrPropertyName: 'val'): N[];
436
452
  /**
437
453
  * Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm and accumulates nodes themselves.
438
454
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
439
455
  * @param {'node'} nodeOrPropertyName - The property of the BinaryTreeNode object to collect at each level.
440
456
  * @returns An array of binary tree nodes.
441
457
  */
442
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
458
+ morris(pattern: DFSOrderPattern, nodeOrPropertyName: 'node'): N[];
443
459
  /**
444
460
  * The function adds a new node to a binary tree if there is an available position.
445
461
  * @param {N | null} newNode - The `newNode` parameter is of type `N | null`, which means it can either be a node of
@@ -456,21 +472,6 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
456
472
  * @param {LoopType} value - The value parameter is of type LoopType.
457
473
  */
458
474
  protected _setLoopType(value: LoopType): void;
459
- /**
460
- * The function sets the value of the `_visitedId` property in a protected manner.
461
- * @param {BinaryTreeNodeId[]} value - value is an array of BinaryTreeNodeId values.
462
- */
463
- protected _setVisitedId(value: BinaryTreeNodeId[]): void;
464
- /**
465
- * The function sets the value of the "_visitedVal" property to the given array.
466
- * @param value - An array of type N.
467
- */
468
- protected _setVisitedVal(value: Array<N>): void;
469
- /**
470
- * The function sets the value of the _visitedNode property.
471
- * @param {N[]} value - N[] is an array of elements of type N.
472
- */
473
- protected _setVisitedNode(value: N[]): void;
474
475
  /**
475
476
  * The function sets the root property of an object to a given value, and if the value is not null, it also sets the
476
477
  * parent property of the value to undefined.
@@ -492,17 +493,17 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
492
493
  * a result array.
493
494
  * @param {N} cur - The current node being processed.
494
495
  * @param {(N | null | undefined)[]} result - An array that stores the matching nodes.
495
- * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter is either a `BinaryTreeNodeId` or a `N`
496
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter is either a `BinaryTreeNodeKey` or a `N`
496
497
  * type. It represents the property value that we are comparing against in the switch statement.
497
498
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
498
- * specifies the property name to compare against when pushing nodes into the `result` array. It can be either `'id'`
499
- * or `'val'`. If it is not provided or is not equal to `'id'` or `'val'`, the
499
+ * specifies the property name to compare against when pushing nodes into the `result` array. It can be either `'key'`
500
+ * or `'val'`. If it is not provided or is not equal to `'key'` or `'val'`, the
500
501
  * @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
501
502
  * stop after finding the first matching node or continue searching for all matching nodes. If `onlyOne` is set to
502
503
  * `true`, the function will stop after finding the first matching node and return `true`. If `onlyOne
503
504
  * @returns a boolean value indicating whether only one matching node should be pushed into the result array.
504
505
  */
505
- protected _pushByPropertyNameStopOrNot(cur: N, result: (N | null | undefined)[], nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): boolean | undefined;
506
+ protected _pushByPropertyNameStopOrNot(cur: N, result: (N | null | undefined)[], nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): boolean | undefined;
506
507
  /**
507
508
  * The function `_accumulatedByPropertyName` accumulates values from a given node based on the specified property name.
508
509
  * @param {N} node - The `node` parameter is of type `N`, which represents a node in a data structure.
@@ -512,7 +513,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
512
513
  */
513
514
  protected _accumulatedByPropertyName(node: N, nodeOrPropertyName?: NodeOrPropertyName): void;
514
515
  /**
515
- * The time complexity of Morris traversal is O(n), it's may slower than others
516
+ * The time complexity of Morris traversal is O(n), it may slower than others
516
517
  * The space complexity Morris traversal is O(1) because no using stack
517
518
  */
518
519
  /**