data-structure-typed 1.18.6 → 1.18.8

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 (262) hide show
  1. package/README.md +154 -366
  2. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +72 -51
  3. package/dist/data-structures/binary-tree/abstract-binary-tree.js +226 -158
  4. package/dist/data-structures/binary-tree/avl-tree.d.ts +7 -6
  5. package/dist/data-structures/binary-tree/avl-tree.js +5 -3
  6. package/dist/data-structures/binary-tree/binary-tree.d.ts +16 -6
  7. package/dist/data-structures/binary-tree/binary-tree.js +16 -7
  8. package/dist/data-structures/binary-tree/bst.d.ts +37 -28
  9. package/dist/data-structures/binary-tree/bst.js +44 -76
  10. package/dist/data-structures/binary-tree/rb-tree.d.ts +30 -1
  11. package/dist/data-structures/binary-tree/rb-tree.js +27 -14
  12. package/dist/data-structures/binary-tree/tree-multiset.d.ts +18 -7
  13. package/dist/data-structures/binary-tree/tree-multiset.js +20 -15
  14. package/dist/data-structures/graph/abstract-graph.d.ts +28 -27
  15. package/dist/data-structures/graph/abstract-graph.js +58 -36
  16. package/dist/data-structures/graph/directed-graph.d.ts +27 -24
  17. package/dist/data-structures/graph/directed-graph.js +65 -60
  18. package/dist/data-structures/graph/undirected-graph.d.ts +12 -18
  19. package/dist/data-structures/graph/undirected-graph.js +52 -65
  20. package/dist/data-structures/interfaces/abstract-binary-tree.d.ts +100 -0
  21. package/dist/data-structures/interfaces/abstract-binary-tree.js +2 -0
  22. package/dist/data-structures/interfaces/abstract-graph.d.ts +3 -8
  23. package/dist/data-structures/interfaces/avl-tree.d.ts +16 -1
  24. package/dist/data-structures/interfaces/binary-tree.d.ts +4 -24
  25. package/dist/data-structures/interfaces/bst.d.ts +18 -1
  26. package/dist/data-structures/interfaces/directed-graph.d.ts +4 -1
  27. package/dist/data-structures/interfaces/index.d.ts +1 -1
  28. package/dist/data-structures/interfaces/index.js +1 -1
  29. package/dist/data-structures/interfaces/rb-tree.d.ts +9 -0
  30. package/dist/data-structures/interfaces/rb-tree.js +2 -0
  31. package/dist/data-structures/interfaces/tree-multiset.d.ts +7 -1
  32. package/dist/data-structures/interfaces/undirected-graph.d.ts +4 -1
  33. package/dist/data-structures/tree/tree.d.ts +1 -4
  34. package/dist/data-structures/tree/tree.js +1 -12
  35. package/dist/data-structures/types/abstract-binary-tree.d.ts +11 -7
  36. package/dist/data-structures/types/abstract-binary-tree.js +9 -5
  37. package/dist/data-structures/types/avl-tree.d.ts +1 -1
  38. package/dist/data-structures/types/binary-tree.d.ts +1 -1
  39. package/dist/data-structures/types/bst.d.ts +1 -1
  40. package/dist/data-structures/types/bst.js +1 -1
  41. package/dist/data-structures/types/directed-graph.js +1 -1
  42. package/dist/data-structures/types/helpers.d.ts +1 -8
  43. package/dist/data-structures/types/rb-tree.d.ts +2 -0
  44. package/dist/data-structures/types/rb-tree.js +1 -1
  45. package/dist/data-structures/types/tree-multiset.d.ts +4 -4
  46. package/dist/utils/types/utils.d.ts +18 -0
  47. package/dist/utils/utils.d.ts +6 -1
  48. package/dist/utils/utils.js +83 -1
  49. package/package.json +2 -2
  50. package/backup/recursive-type/src/assets/complexities-diff.jpg +0 -0
  51. package/backup/recursive-type/src/assets/data-structure-complexities.jpg +0 -0
  52. package/backup/recursive-type/src/assets/logo.png +0 -0
  53. package/backup/recursive-type/src/assets/overview-diagram-of-data-structures.png +0 -0
  54. package/backup/recursive-type/src/data-structures/binary-tree/aa-tree.ts +0 -3
  55. package/backup/recursive-type/src/data-structures/binary-tree/avl-tree.ts +0 -288
  56. package/backup/recursive-type/src/data-structures/binary-tree/b-tree.ts +0 -3
  57. package/backup/recursive-type/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -78
  58. package/backup/recursive-type/src/data-structures/binary-tree/binary-tree.ts +0 -1502
  59. package/backup/recursive-type/src/data-structures/binary-tree/bst.ts +0 -503
  60. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
  61. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
  62. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
  63. package/backup/recursive-type/src/data-structures/binary-tree/index.ts +0 -11
  64. package/backup/recursive-type/src/data-structures/binary-tree/rb-tree.ts +0 -110
  65. package/backup/recursive-type/src/data-structures/binary-tree/segment-tree.ts +0 -243
  66. package/backup/recursive-type/src/data-structures/binary-tree/splay-tree.ts +0 -3
  67. package/backup/recursive-type/src/data-structures/binary-tree/tree-multiset.ts +0 -55
  68. package/backup/recursive-type/src/data-structures/binary-tree/two-three-tree.ts +0 -3
  69. package/backup/recursive-type/src/data-structures/diagrams/README.md +0 -5
  70. package/backup/recursive-type/src/data-structures/graph/abstract-graph.ts +0 -985
  71. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
  72. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
  73. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
  74. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
  75. package/backup/recursive-type/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
  76. package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
  77. package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
  78. package/backup/recursive-type/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
  79. package/backup/recursive-type/src/data-structures/graph/diagrams/mst.jpg +0 -0
  80. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
  81. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
  82. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
  83. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
  84. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.webp +0 -0
  85. package/backup/recursive-type/src/data-structures/graph/directed-graph.ts +0 -478
  86. package/backup/recursive-type/src/data-structures/graph/index.ts +0 -3
  87. package/backup/recursive-type/src/data-structures/graph/undirected-graph.ts +0 -293
  88. package/backup/recursive-type/src/data-structures/hash/coordinate-map.ts +0 -67
  89. package/backup/recursive-type/src/data-structures/hash/coordinate-set.ts +0 -56
  90. package/backup/recursive-type/src/data-structures/hash/hash-table.ts +0 -3
  91. package/backup/recursive-type/src/data-structures/hash/index.ts +0 -6
  92. package/backup/recursive-type/src/data-structures/hash/pair.ts +0 -3
  93. package/backup/recursive-type/src/data-structures/hash/tree-map.ts +0 -3
  94. package/backup/recursive-type/src/data-structures/hash/tree-set.ts +0 -3
  95. package/backup/recursive-type/src/data-structures/heap/heap.ts +0 -176
  96. package/backup/recursive-type/src/data-structures/heap/index.ts +0 -3
  97. package/backup/recursive-type/src/data-structures/heap/max-heap.ts +0 -31
  98. package/backup/recursive-type/src/data-structures/heap/min-heap.ts +0 -34
  99. package/backup/recursive-type/src/data-structures/index.ts +0 -15
  100. package/backup/recursive-type/src/data-structures/interfaces/abstract-graph.ts +0 -42
  101. package/backup/recursive-type/src/data-structures/interfaces/avl-tree.ts +0 -1
  102. package/backup/recursive-type/src/data-structures/interfaces/binary-tree.ts +0 -56
  103. package/backup/recursive-type/src/data-structures/interfaces/bst.ts +0 -1
  104. package/backup/recursive-type/src/data-structures/interfaces/directed-graph.ts +0 -15
  105. package/backup/recursive-type/src/data-structures/interfaces/doubly-linked-list.ts +0 -1
  106. package/backup/recursive-type/src/data-structures/interfaces/heap.ts +0 -1
  107. package/backup/recursive-type/src/data-structures/interfaces/index.ts +0 -13
  108. package/backup/recursive-type/src/data-structures/interfaces/navigator.ts +0 -1
  109. package/backup/recursive-type/src/data-structures/interfaces/priority-queue.ts +0 -1
  110. package/backup/recursive-type/src/data-structures/interfaces/segment-tree.ts +0 -1
  111. package/backup/recursive-type/src/data-structures/interfaces/singly-linked-list.ts +0 -1
  112. package/backup/recursive-type/src/data-structures/interfaces/tree-multiset.ts +0 -1
  113. package/backup/recursive-type/src/data-structures/interfaces/undirected-graph.ts +0 -3
  114. package/backup/recursive-type/src/data-structures/linked-list/doubly-linked-list.ts +0 -573
  115. package/backup/recursive-type/src/data-structures/linked-list/index.ts +0 -3
  116. package/backup/recursive-type/src/data-structures/linked-list/singly-linked-list.ts +0 -490
  117. package/backup/recursive-type/src/data-structures/linked-list/skip-linked-list.ts +0 -3
  118. package/backup/recursive-type/src/data-structures/matrix/index.ts +0 -4
  119. package/backup/recursive-type/src/data-structures/matrix/matrix.ts +0 -27
  120. package/backup/recursive-type/src/data-structures/matrix/matrix2d.ts +0 -208
  121. package/backup/recursive-type/src/data-structures/matrix/navigator.ts +0 -122
  122. package/backup/recursive-type/src/data-structures/matrix/vector2d.ts +0 -316
  123. package/backup/recursive-type/src/data-structures/priority-queue/index.ts +0 -3
  124. package/backup/recursive-type/src/data-structures/priority-queue/max-priority-queue.ts +0 -49
  125. package/backup/recursive-type/src/data-structures/priority-queue/min-priority-queue.ts +0 -50
  126. package/backup/recursive-type/src/data-structures/priority-queue/priority-queue.ts +0 -354
  127. package/backup/recursive-type/src/data-structures/queue/deque.ts +0 -251
  128. package/backup/recursive-type/src/data-structures/queue/index.ts +0 -2
  129. package/backup/recursive-type/src/data-structures/queue/queue.ts +0 -120
  130. package/backup/recursive-type/src/data-structures/stack/index.ts +0 -1
  131. package/backup/recursive-type/src/data-structures/stack/stack.ts +0 -98
  132. package/backup/recursive-type/src/data-structures/tree/index.ts +0 -1
  133. package/backup/recursive-type/src/data-structures/tree/tree.ts +0 -80
  134. package/backup/recursive-type/src/data-structures/trie/index.ts +0 -1
  135. package/backup/recursive-type/src/data-structures/trie/trie.ts +0 -227
  136. package/backup/recursive-type/src/data-structures/types/abstract-graph.ts +0 -5
  137. package/backup/recursive-type/src/data-structures/types/avl-tree.ts +0 -8
  138. package/backup/recursive-type/src/data-structures/types/binary-tree.ts +0 -10
  139. package/backup/recursive-type/src/data-structures/types/bst.ts +0 -6
  140. package/backup/recursive-type/src/data-structures/types/directed-graph.ts +0 -8
  141. package/backup/recursive-type/src/data-structures/types/doubly-linked-list.ts +0 -1
  142. package/backup/recursive-type/src/data-structures/types/heap.ts +0 -5
  143. package/backup/recursive-type/src/data-structures/types/index.ts +0 -12
  144. package/backup/recursive-type/src/data-structures/types/navigator.ts +0 -13
  145. package/backup/recursive-type/src/data-structures/types/priority-queue.ts +0 -9
  146. package/backup/recursive-type/src/data-structures/types/segment-tree.ts +0 -1
  147. package/backup/recursive-type/src/data-structures/types/singly-linked-list.ts +0 -1
  148. package/backup/recursive-type/src/data-structures/types/tree-multiset.ts +0 -1
  149. package/backup/recursive-type/src/index.ts +0 -1
  150. package/backup/recursive-type/src/utils/index.ts +0 -2
  151. package/backup/recursive-type/src/utils/types/index.ts +0 -1
  152. package/backup/recursive-type/src/utils/types/utils.ts +0 -6
  153. package/backup/recursive-type/src/utils/utils.ts +0 -78
  154. package/docs/.nojekyll +0 -1
  155. package/docs/assets/highlight.css +0 -92
  156. package/docs/assets/main.js +0 -58
  157. package/docs/assets/search.js +0 -1
  158. package/docs/assets/style.css +0 -1367
  159. package/docs/classes/AVLTree.html +0 -2339
  160. package/docs/classes/AVLTreeNode.html +0 -450
  161. package/docs/classes/AaTree.html +0 -166
  162. package/docs/classes/AbstractBinaryTree.html +0 -2023
  163. package/docs/classes/AbstractBinaryTreeNode.html +0 -491
  164. package/docs/classes/AbstractEdge.html +0 -289
  165. package/docs/classes/AbstractGraph.html +0 -1046
  166. package/docs/classes/AbstractVertex.html +0 -252
  167. package/docs/classes/ArrayDeque.html +0 -433
  168. package/docs/classes/BST.html +0 -2196
  169. package/docs/classes/BSTNode.html +0 -453
  170. package/docs/classes/BTree.html +0 -166
  171. package/docs/classes/BinaryIndexedTree.html +0 -335
  172. package/docs/classes/BinaryTree.html +0 -2037
  173. package/docs/classes/BinaryTreeNode.html +0 -452
  174. package/docs/classes/Character.html +0 -214
  175. package/docs/classes/CoordinateMap.html +0 -477
  176. package/docs/classes/CoordinateSet.html +0 -438
  177. package/docs/classes/Deque.html +0 -969
  178. package/docs/classes/DirectedEdge.html +0 -360
  179. package/docs/classes/DirectedGraph.html +0 -1408
  180. package/docs/classes/DirectedVertex.html +0 -248
  181. package/docs/classes/DoublyLinkedList.html +0 -962
  182. package/docs/classes/DoublyLinkedListNode.html +0 -291
  183. package/docs/classes/HashTable.html +0 -166
  184. package/docs/classes/Heap.html +0 -417
  185. package/docs/classes/HeapItem.html +0 -249
  186. package/docs/classes/Matrix2D.html +0 -496
  187. package/docs/classes/MatrixNTI2D.html +0 -234
  188. package/docs/classes/MaxHeap.html +0 -430
  189. package/docs/classes/MaxPriorityQueue.html +0 -830
  190. package/docs/classes/MinHeap.html +0 -431
  191. package/docs/classes/MinPriorityQueue.html +0 -832
  192. package/docs/classes/Navigator.html +0 -307
  193. package/docs/classes/ObjectDeque.html +0 -449
  194. package/docs/classes/Pair.html +0 -166
  195. package/docs/classes/PriorityQueue.html +0 -754
  196. package/docs/classes/Queue.html +0 -386
  197. package/docs/classes/SegmentTree.html +0 -428
  198. package/docs/classes/SegmentTreeNode.html +0 -351
  199. package/docs/classes/SinglyLinkedList.html +0 -782
  200. package/docs/classes/SinglyLinkedListNode.html +0 -264
  201. package/docs/classes/SkipLinkedList.html +0 -166
  202. package/docs/classes/SplayTree.html +0 -166
  203. package/docs/classes/Stack.html +0 -362
  204. package/docs/classes/TreeMap.html +0 -166
  205. package/docs/classes/TreeMultiSet.html +0 -2196
  206. package/docs/classes/TreeMultiSetNode.html +0 -450
  207. package/docs/classes/TreeNode.html +0 -337
  208. package/docs/classes/TreeSet.html +0 -166
  209. package/docs/classes/Trie.html +0 -366
  210. package/docs/classes/TrieNode.html +0 -274
  211. package/docs/classes/TwoThreeTree.html +0 -166
  212. package/docs/classes/UndirectedEdge.html +0 -331
  213. package/docs/classes/UndirectedGraph.html +0 -1196
  214. package/docs/classes/UndirectedVertex.html +0 -248
  215. package/docs/classes/Vector2D.html +0 -799
  216. package/docs/enums/CP.html +0 -175
  217. package/docs/enums/FamilyPosition.html +0 -175
  218. package/docs/enums/LoopType.html +0 -176
  219. package/docs/enums/RBColor.html +0 -168
  220. package/docs/enums/TopologicalProperty.html +0 -175
  221. package/docs/index.html +0 -639
  222. package/docs/interfaces/IBinaryTree.html +0 -189
  223. package/docs/interfaces/IBinaryTreeNode.html +0 -396
  224. package/docs/interfaces/IDirectedGraph.html +0 -259
  225. package/docs/interfaces/IGraph.html +0 -471
  226. package/docs/interfaces/IUNDirectedGraph.html +0 -151
  227. package/docs/modules.html +0 -250
  228. package/docs/types/AVLTreeOptions.html +0 -144
  229. package/docs/types/AbstractBinaryTreeOptions.html +0 -150
  230. package/docs/types/AbstractRecursiveBinaryTreeNode.html +0 -146
  231. package/docs/types/AbstractResultByProperty.html +0 -146
  232. package/docs/types/AbstractResultsByProperty.html +0 -146
  233. package/docs/types/BSTComparator.html +0 -156
  234. package/docs/types/BSTOptions.html +0 -146
  235. package/docs/types/BinaryTreeDeletedResult.html +0 -153
  236. package/docs/types/BinaryTreeNodeId.html +0 -141
  237. package/docs/types/BinaryTreeNodePropertyName.html +0 -141
  238. package/docs/types/BinaryTreeOptions.html +0 -144
  239. package/docs/types/DFSOrderPattern.html +0 -141
  240. package/docs/types/DijkstraResult.html +0 -161
  241. package/docs/types/Direction.html +0 -141
  242. package/docs/types/EdgeId.html +0 -141
  243. package/docs/types/HeapOptions.html +0 -162
  244. package/docs/types/IdObject.html +0 -151
  245. package/docs/types/KeyValObject.html +0 -146
  246. package/docs/types/NavigatorParams.html +0 -175
  247. package/docs/types/NodeOrPropertyName.html +0 -141
  248. package/docs/types/PriorityQueueComparator.html +0 -161
  249. package/docs/types/PriorityQueueDFSOrderPattern.html +0 -141
  250. package/docs/types/PriorityQueueOptions.html +0 -155
  251. package/docs/types/RBTreeOptions.html +0 -144
  252. package/docs/types/RecursiveAVLTreeNode.html +0 -146
  253. package/docs/types/RecursiveBSTNode.html +0 -146
  254. package/docs/types/RecursiveBinaryTreeNode.html +0 -146
  255. package/docs/types/RecursiveTreeMultiSetNode.html +0 -146
  256. package/docs/types/SegmentTreeNodeVal.html +0 -141
  257. package/docs/types/TopologicalStatus.html +0 -141
  258. package/docs/types/TreeMultiSetOptions.html +0 -146
  259. package/docs/types/Turning.html +0 -141
  260. package/docs/types/VertexId.html +0 -141
  261. package/notes/bst.test.ts +0 -181
  262. package/notes/note.md +0 -34
@@ -5,17 +5,26 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { AbstractRecursiveBinaryTreeNode, AbstractResultsByProperty, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName } from '../types';
8
+ import type { AbstractBinaryTreeNodeNested, AbstractBinaryTreeNodeProperties, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName } from '../types';
9
9
  import { AbstractBinaryTreeOptions, FamilyPosition, LoopType } from '../types';
10
- import { IBinaryTree, IBinaryTreeNode } from '../interfaces';
11
- export declare abstract class AbstractBinaryTreeNode<T, FAMILY extends AbstractBinaryTreeNode<T, FAMILY> = AbstractRecursiveBinaryTreeNode<T>> implements IBinaryTreeNode<T, FAMILY> {
12
- constructor(id: BinaryTreeNodeId, val: T, count?: number);
10
+ import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from '../interfaces';
11
+ export declare abstract class AbstractBinaryTreeNode<T = any, FAMILY extends AbstractBinaryTreeNode<T, FAMILY> = AbstractBinaryTreeNodeNested<T>> implements IAbstractBinaryTreeNode<T, FAMILY> {
12
+ /**
13
+ * The constructor function initializes a BinaryTreeNode object with an id, value, and count.
14
+ * @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
15
+ * for the binary tree node.
16
+ * @param {T} [val] - The `val` parameter is an optional parameter of type `T`. It represents the value of the binary
17
+ * tree node. If no value is provided, it will be `undefined`.
18
+ * @param {number} [count] - The `count` parameter is an optional parameter that represents the number of times the
19
+ * value `val` appears in the binary tree node. If the `count` parameter is not provided, it defaults to 1.
20
+ */
21
+ constructor(id: BinaryTreeNodeId, val?: T, count?: number);
13
22
  private _id;
14
23
  get id(): BinaryTreeNodeId;
15
24
  set id(v: BinaryTreeNodeId);
16
25
  private _val;
17
- get val(): T;
18
- set val(v: T);
26
+ get val(): T | undefined;
27
+ set val(value: T | undefined);
19
28
  private _left?;
20
29
  get left(): FAMILY | null | undefined;
21
30
  set left(v: FAMILY | null | undefined);
@@ -25,20 +34,28 @@ export declare abstract class AbstractBinaryTreeNode<T, FAMILY extends AbstractB
25
34
  private _parent;
26
35
  get parent(): FAMILY | null | undefined;
27
36
  set parent(v: FAMILY | null | undefined);
28
- private _familyPosition;
29
- get familyPosition(): FamilyPosition;
30
- set familyPosition(v: FamilyPosition);
31
37
  private _count;
32
38
  get count(): number;
33
39
  set count(v: number);
34
40
  private _height;
35
41
  get height(): number;
36
42
  set height(v: number);
37
- abstract _createNode(id: BinaryTreeNodeId, val: T | null, count?: number): FAMILY | null;
38
- swapLocation(swapNode: FAMILY): FAMILY;
43
+ get familyPosition(): FamilyPosition;
44
+ abstract createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
45
+ /**
46
+ * The function swaps the location of two nodes in a binary tree.
47
+ * @param {FAMILY} destNode - The `swapNode` parameter is of type `FAMILY`, which represents a node in a family tree.
48
+ * @returns the `swapNode` object after swapping its properties with the properties of `this` object.
49
+ */
50
+ swapLocation(destNode: FAMILY): FAMILY;
51
+ /**
52
+ * The `clone` function returns a new instance of the `FAMILY` class with the same `id`, `val`, and `count` properties.
53
+ * @returns The `clone()` method is returning a new instance of the `FAMILY` class with the same `id`, `val`, and
54
+ * `count` values as the current instance.
55
+ */
39
56
  clone(): FAMILY | null;
40
57
  }
41
- export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N> = AbstractBinaryTreeNode<number>> implements IBinaryTree<N> {
58
+ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N> = AbstractBinaryTreeNode> implements IAbstractBinaryTree<N> {
42
59
  /**
43
60
  * The protected constructor initializes the options for an abstract binary tree.
44
61
  * @param {AbstractBinaryTreeOptions} [options] - An optional object that contains configuration options for the binary
@@ -61,15 +78,15 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
61
78
  get autoIncrementId(): boolean;
62
79
  private _maxId;
63
80
  get maxId(): number;
64
- private _isDuplicatedVal;
65
- get isDuplicatedVal(): boolean;
81
+ private _isMergeDuplicatedVal;
82
+ get isMergeDuplicatedVal(): boolean;
66
83
  private _root;
67
84
  get root(): N | null;
68
85
  private _size;
69
86
  get size(): number;
70
87
  private _count;
71
88
  get count(): number;
72
- abstract _createNode(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
89
+ abstract createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null;
73
90
  /**
74
91
  * The clear function resets the state of an object by setting its properties to their initial values.
75
92
  */
@@ -92,12 +109,13 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
92
109
  */
93
110
  add(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null | undefined;
94
111
  /**
95
- * The function inserts a new node into a binary tree as the left or right child of a given parent node.
96
- * @param {N | null} newNode - The `newNode` parameter is an instance of the `BinaryTreeNode` class or
97
- * `null`. It represents the node that needs to be inserted into the binary tree.
98
- * @param parent - The `parent` parameter is a BinaryTreeNode object representing the parent node to which the new node
99
- * will be inserted as a child.
100
- * @returns The method returns the newly inserted node, either as the left child or the right child of the parent node.
112
+ * The function adds a new node to a binary tree as the left or right child of a given parent node.
113
+ * @param {N | null} newNode - The `newNode` parameter represents the node that you want to add to the tree. It can be
114
+ * either a node object (`N`) or `null`.
115
+ * @param {N} parent - The `parent` parameter represents the parent node to which the new node will be added as a
116
+ * child.
117
+ * @returns either the left or right child node that was added to the parent node. It can also return `null` or
118
+ * `undefined` in certain cases.
101
119
  */
102
120
  addTo(newNode: N | null, parent: N): N | null | undefined;
103
121
  /**
@@ -117,24 +135,21 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
117
135
  */
118
136
  fill(data: N[] | Array<N['val']>): boolean;
119
137
  /**
120
- * The function removes a node from a binary tree and returns information about the deleted node.
121
- * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier of the binary tree node that you want to remove.
122
- * It is of type `BinaryTreeNodeId`.
138
+ * The `remove` function removes a node from a binary search tree and returns the deleted node along with the parent
139
+ * node that needs to be balanced.
140
+ * @param {N | BinaryTreeNodeId | null} nodeOrId - The `nodeOrId` parameter can be one of the following:
123
141
  * @param {boolean} [ignoreCount] - The `ignoreCount` parameter is an optional boolean parameter that determines
124
142
  * whether to ignore the count of the node being removed. If `ignoreCount` is set to `true`, the count of the node will
125
- * not be decremented and the overall count of the binary tree will not be updated. If `
126
- * @returns An array of objects is being returned. Each object in the array has two properties: "deleted" and
127
- * "needBalanced". The "deleted" property contains the deleted node or undefined if no node was deleted. The
128
- * "needBalanced" property is always null.
143
+ * not be taken into account when removing it. If `ignoreCount` is set to `false
144
+ * @returns The function `remove` returns an array of `BinaryTreeDeletedResult<N>` objects.
129
145
  */
130
- remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
146
+ remove(nodeOrId: N | BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
131
147
  /**
132
- * The function calculates the depth of a binary tree node by traversing its parent nodes.
133
- * @param node - N - This is the node for which we want to calculate the depth. It is a generic type,
134
- * meaning it can represent any type of data that we want to store in the node.
135
- * @returns The depth of the given binary tree node.
148
+ * The function calculates the depth of a node in a binary tree.
149
+ * @param {N | BinaryTreeNodeId | null} beginRoot - The `beginRoot` parameter can be one of the following:
150
+ * @returns the depth of the given node or binary tree.
136
151
  */
137
- getDepth(node: N): number;
152
+ getDepth(beginRoot: N | BinaryTreeNodeId | null): number;
138
153
  /**
139
154
  * The `getHeight` function calculates the maximum height of a binary tree using either a recursive or iterative
140
155
  * approach.
@@ -143,7 +158,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
143
158
  * If no value is provided for `beginRoot`, the function will use the `root` property of the class instance as
144
159
  * @returns the height of the binary tree.
145
160
  */
146
- getHeight(beginRoot?: N | null): number;
161
+ getHeight(beginRoot?: N | BinaryTreeNodeId | null): number;
147
162
  /**
148
163
  * The `getMinHeight` function calculates the minimum height of a binary tree using either a recursive or iterative
149
164
  * approach.
@@ -172,7 +187,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
172
187
  * function will stop traversing the tree and return the first matching node. If `
173
188
  * @returns The function `getNodes` returns an array of `N | null | undefined` objects.
174
189
  */
175
- getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): (N | null | undefined)[];
190
+ getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
176
191
  /**
177
192
  * The function checks if a binary tree node has a specific property or if any node in the tree has a specific
178
193
  * property.
@@ -206,12 +221,16 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
206
221
  getRightMost(): N | null;
207
222
  getRightMost(node: N): N;
208
223
  /**
209
- * The `isBST` function checks if a binary tree is a binary search tree.
210
- * @param {N | null} [node] - The `node` parameter is an optional parameter of type `N
211
- * | null`. It represents the root node of the binary search tree (BST) that we want to check for validity. If no node
212
- * is provided, the function will default to using the root node of the BST instance that
213
- * @returns The `isBST` function returns a boolean value. It returns `true` if the binary tree is a valid binary search
214
- * tree, and `false` otherwise.
224
+ * The function `isBSTByRooted` checks if a binary tree is a binary search tree (BST) by rooted traversal.
225
+ * @param {N | null} node - The `node` parameter represents the root node of a binary search tree (BST).
226
+ * @returns a boolean value.
227
+ */
228
+ isBSTByRooted(node: N | null): boolean;
229
+ /**
230
+ * The function checks if a binary tree is a binary search tree.
231
+ * @param {N | null} [node] - The `node` parameter is of type `N` or `null`. It represents the root node of a binary
232
+ * search tree (BST).
233
+ * @returns a boolean value.
215
234
  */
216
235
  isBST(node?: N | null): boolean;
217
236
  /**
@@ -233,17 +252,19 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
233
252
  * provided, it defaults to `'val'`.
234
253
  * @returns a number, which is the sum of the values of the nodes in the subtree rooted at `subTreeRoot`.
235
254
  */
236
- subTreeSum(subTreeRoot: N, propertyName?: BinaryTreeNodePropertyName): number;
255
+ subTreeSum(subTreeRoot: N | BinaryTreeNodeId | null, propertyName?: BinaryTreeNodePropertyName): number;
237
256
  /**
238
- * The function `subTreeAdd` adds a specified delta value to a property of each node in a binary tree.
239
- * @param subTreeRoot - The `subTreeRoot` parameter is the root node of the subtree where the values will be modified.
257
+ * The function `subTreeAdd` adds a delta value to a specified property of each node in a subtree.
258
+ * @param {N | BinaryTreeNodeId | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
259
+ * tree or the ID of a binary tree node. It can also be `null` if there is no subtree root.
240
260
  * @param {number} delta - The `delta` parameter is a number that represents the amount by which the property value of
241
- * each node in the subtree should be increased or decreased.
261
+ * each node in the subtree should be incremented or decremented.
242
262
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
243
- * specifies the property of the `BinaryTreeNode` that should be modified. It defaults to `'id'` if not provided.
244
- * @returns a boolean value, which is `true`.
263
+ * specifies the property of the binary tree node that should be modified. It can be either 'id' or 'count'. If no
264
+ * value is provided for `propertyName`, it defaults to 'id'.
265
+ * @returns a boolean value.
245
266
  */
246
- subTreeAdd(subTreeRoot: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
267
+ subTreeAdd(subTreeRoot: N | BinaryTreeNodeId | null, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
247
268
  BFS(): BinaryTreeNodeId[];
248
269
  BFS(nodeOrPropertyName: 'id'): BinaryTreeNodeId[];
249
270
  BFS(nodeOrPropertyName: 'val'): N['val'][];
@@ -327,7 +348,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
327
348
  * to 'id'.
328
349
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The parameter `nodeOrPropertyName` is an optional parameter that
329
350
  * can accept a value of type `NodeOrPropertyName`.
330
- * @returns The method returns an object of type `AbstractResultsByProperty<T>`.
351
+ * @returns The method returns an object of type `AbstractBinaryTreeNodeProperties<T>`.
331
352
  */
332
- protected _getResultByPropertyName(nodeOrPropertyName?: NodeOrPropertyName): AbstractResultsByProperty<N>;
353
+ protected _getResultByPropertyName(nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
333
354
  }