data-structure-typed 1.32.2 → 1.33.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 (252) hide show
  1. package/.eslintrc.json +58 -0
  2. package/.idea/data-structure-typed.iml +19 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. package/.idea/misc.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/vcs.xml +6 -0
  7. package/.prettierrc +16 -0
  8. package/.travis.yml +17 -0
  9. package/CHANGELOG.md +1 -1
  10. package/README.md +366 -76
  11. package/coverage/coverage-final.json +4 -4
  12. package/docs/index.html +260 -9
  13. package/package.json +50 -18
  14. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +46 -1
  15. package/.eslintrc.js +0 -61
  16. package/.prettierrc.js +0 -16
  17. package/coverage/clover.xml +0 -3393
  18. package/coverage/lcov-report/base.css +0 -224
  19. package/coverage/lcov-report/block-navigation.js +0 -87
  20. package/coverage/lcov-report/favicon.png +0 -0
  21. package/coverage/lcov-report/index.html +0 -386
  22. package/coverage/lcov-report/prettify.css +0 -1
  23. package/coverage/lcov-report/prettify.js +0 -2
  24. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  25. package/coverage/lcov-report/sorter.js +0 -196
  26. package/coverage/lcov-report/src/data-structures/binary-tree/aa-tree.ts.html +0 -88
  27. package/coverage/lcov-report/src/data-structures/binary-tree/abstract-binary-tree.ts.html +0 -4978
  28. package/coverage/lcov-report/src/data-structures/binary-tree/avl-tree.ts.html +0 -1015
  29. package/coverage/lcov-report/src/data-structures/binary-tree/b-tree.ts.html +0 -88
  30. package/coverage/lcov-report/src/data-structures/binary-tree/binary-indexed-tree.ts.html +0 -313
  31. package/coverage/lcov-report/src/data-structures/binary-tree/binary-tree.ts.html +0 -226
  32. package/coverage/lcov-report/src/data-structures/binary-tree/bst.ts.html +0 -1696
  33. package/coverage/lcov-report/src/data-structures/binary-tree/index.html +0 -296
  34. package/coverage/lcov-report/src/data-structures/binary-tree/index.ts.html +0 -121
  35. package/coverage/lcov-report/src/data-structures/binary-tree/rb-tree.ts.html +0 -388
  36. package/coverage/lcov-report/src/data-structures/binary-tree/segment-tree.ts.html +0 -811
  37. package/coverage/lcov-report/src/data-structures/binary-tree/splay-tree.ts.html +0 -88
  38. package/coverage/lcov-report/src/data-structures/binary-tree/tree-multiset.ts.html +0 -2185
  39. package/coverage/lcov-report/src/data-structures/binary-tree/two-three-tree.ts.html +0 -88
  40. package/coverage/lcov-report/src/data-structures/graph/abstract-graph.ts.html +0 -3205
  41. package/coverage/lcov-report/src/data-structures/graph/directed-graph.ts.html +0 -1495
  42. package/coverage/lcov-report/src/data-structures/graph/index.html +0 -176
  43. package/coverage/lcov-report/src/data-structures/graph/index.ts.html +0 -97
  44. package/coverage/lcov-report/src/data-structures/graph/map-graph.ts.html +0 -472
  45. package/coverage/lcov-report/src/data-structures/graph/undirected-graph.ts.html +0 -907
  46. package/coverage/lcov-report/src/data-structures/hash/coordinate-map.ts.html +0 -286
  47. package/coverage/lcov-report/src/data-structures/hash/coordinate-set.ts.html +0 -253
  48. package/coverage/lcov-report/src/data-structures/hash/hash-table.ts.html +0 -88
  49. package/coverage/lcov-report/src/data-structures/hash/index.html +0 -206
  50. package/coverage/lcov-report/src/data-structures/hash/index.ts.html +0 -103
  51. package/coverage/lcov-report/src/data-structures/hash/pair.ts.html +0 -88
  52. package/coverage/lcov-report/src/data-structures/hash/tree-map.ts.html +0 -88
  53. package/coverage/lcov-report/src/data-structures/hash/tree-set.ts.html +0 -88
  54. package/coverage/lcov-report/src/data-structures/heap/heap.ts.html +0 -721
  55. package/coverage/lcov-report/src/data-structures/heap/index.html +0 -161
  56. package/coverage/lcov-report/src/data-structures/heap/index.ts.html +0 -94
  57. package/coverage/lcov-report/src/data-structures/heap/max-heap.ts.html +0 -178
  58. package/coverage/lcov-report/src/data-structures/heap/min-heap.ts.html +0 -181
  59. package/coverage/lcov-report/src/data-structures/index.html +0 -116
  60. package/coverage/lcov-report/src/data-structures/index.ts.html +0 -118
  61. package/coverage/lcov-report/src/data-structures/linked-list/doubly-linked-list.ts.html +0 -1804
  62. package/coverage/lcov-report/src/data-structures/linked-list/index.html +0 -161
  63. package/coverage/lcov-report/src/data-structures/linked-list/index.ts.html +0 -94
  64. package/coverage/lcov-report/src/data-structures/linked-list/singly-linked-list.ts.html +0 -1588
  65. package/coverage/lcov-report/src/data-structures/linked-list/skip-linked-list.ts.html +0 -88
  66. package/coverage/lcov-report/src/data-structures/matrix/index.html +0 -176
  67. package/coverage/lcov-report/src/data-structures/matrix/index.ts.html +0 -97
  68. package/coverage/lcov-report/src/data-structures/matrix/matrix.ts.html +0 -166
  69. package/coverage/lcov-report/src/data-structures/matrix/matrix2d.ts.html +0 -721
  70. package/coverage/lcov-report/src/data-structures/matrix/navigator.ts.html +0 -448
  71. package/coverage/lcov-report/src/data-structures/matrix/vector2d.ts.html +0 -1033
  72. package/coverage/lcov-report/src/data-structures/priority-queue/index.html +0 -161
  73. package/coverage/lcov-report/src/data-structures/priority-queue/index.ts.html +0 -94
  74. package/coverage/lcov-report/src/data-structures/priority-queue/max-priority-queue.ts.html +0 -253
  75. package/coverage/lcov-report/src/data-structures/priority-queue/min-priority-queue.ts.html +0 -256
  76. package/coverage/lcov-report/src/data-structures/priority-queue/priority-queue.ts.html +0 -1162
  77. package/coverage/lcov-report/src/data-structures/queue/deque.ts.html +0 -976
  78. package/coverage/lcov-report/src/data-structures/queue/index.html +0 -146
  79. package/coverage/lcov-report/src/data-structures/queue/index.ts.html +0 -91
  80. package/coverage/lcov-report/src/data-structures/queue/queue.ts.html +0 -658
  81. package/coverage/lcov-report/src/data-structures/stack/index.html +0 -131
  82. package/coverage/lcov-report/src/data-structures/stack/index.ts.html +0 -88
  83. package/coverage/lcov-report/src/data-structures/stack/stack.ts.html +0 -379
  84. package/coverage/lcov-report/src/data-structures/tree/index.html +0 -131
  85. package/coverage/lcov-report/src/data-structures/tree/index.ts.html +0 -88
  86. package/coverage/lcov-report/src/data-structures/tree/tree.ts.html +0 -292
  87. package/coverage/lcov-report/src/data-structures/trie/index.html +0 -131
  88. package/coverage/lcov-report/src/data-structures/trie/index.ts.html +0 -88
  89. package/coverage/lcov-report/src/data-structures/trie/trie.ts.html +0 -760
  90. package/coverage/lcov-report/src/index.html +0 -116
  91. package/coverage/lcov-report/src/index.ts.html +0 -97
  92. package/coverage/lcov-report/src/interfaces/index.html +0 -116
  93. package/coverage/lcov-report/src/interfaces/index.ts.html +0 -130
  94. package/coverage/lcov-report/src/types/data-structures/abstract-binary-tree.ts.html +0 -235
  95. package/coverage/lcov-report/src/types/data-structures/bst.ts.html +0 -124
  96. package/coverage/lcov-report/src/types/data-structures/directed-graph.ts.html +0 -109
  97. package/coverage/lcov-report/src/types/data-structures/index.html +0 -176
  98. package/coverage/lcov-report/src/types/data-structures/index.ts.html +0 -130
  99. package/coverage/lcov-report/src/types/data-structures/rb-tree.ts.html +0 -106
  100. package/coverage/lcov-report/src/types/index.html +0 -116
  101. package/coverage/lcov-report/src/types/index.ts.html +0 -94
  102. package/coverage/lcov-report/src/types/utils/index.html +0 -116
  103. package/coverage/lcov-report/src/types/utils/index.ts.html +0 -91
  104. package/coverage/lcov-report/src/utils/index.html +0 -131
  105. package/coverage/lcov-report/src/utils/index.ts.html +0 -88
  106. package/coverage/lcov-report/src/utils/utils.ts.html +0 -322
  107. package/coverage/lcov-report/test/utils/index.html +0 -146
  108. package/coverage/lcov-report/test/utils/index.ts.html +0 -91
  109. package/coverage/lcov-report/test/utils/magnitude.ts.html +0 -148
  110. package/coverage/lcov-report/test/utils/number.ts.html +0 -94
  111. package/coverage/lcov.info +0 -6676
  112. package/docs/assets/highlight.css +0 -127
  113. package/docs/assets/main.js +0 -58
  114. package/docs/assets/search.js +0 -1
  115. package/docs/assets/style.css +0 -1367
  116. package/docs/classes/AVLTree.html +0 -2182
  117. package/docs/classes/AVLTreeNode.html +0 -399
  118. package/docs/classes/AaTree.html +0 -202
  119. package/docs/classes/AbstractBinaryTree.html +0 -1836
  120. package/docs/classes/AbstractBinaryTreeNode.html +0 -441
  121. package/docs/classes/AbstractEdge.html +0 -345
  122. package/docs/classes/AbstractGraph.html +0 -1105
  123. package/docs/classes/AbstractVertex.html +0 -299
  124. package/docs/classes/ArrayDeque.html +0 -469
  125. package/docs/classes/BST.html +0 -2026
  126. package/docs/classes/BSTNode.html +0 -400
  127. package/docs/classes/BTree.html +0 -202
  128. package/docs/classes/BinaryIndexedTree.html +0 -371
  129. package/docs/classes/BinaryTree.html +0 -1867
  130. package/docs/classes/BinaryTreeNode.html +0 -399
  131. package/docs/classes/Character.html +0 -250
  132. package/docs/classes/CoordinateMap.html +0 -513
  133. package/docs/classes/CoordinateSet.html +0 -474
  134. package/docs/classes/Deque.html +0 -1005
  135. package/docs/classes/DirectedEdge.html +0 -404
  136. package/docs/classes/DirectedGraph.html +0 -1530
  137. package/docs/classes/DirectedVertex.html +0 -286
  138. package/docs/classes/DoublyLinkedList.html +0 -998
  139. package/docs/classes/DoublyLinkedListNode.html +0 -327
  140. package/docs/classes/HashTable.html +0 -202
  141. package/docs/classes/Heap.html +0 -647
  142. package/docs/classes/HeapItem.html +0 -296
  143. package/docs/classes/LinkedListQueue.html +0 -884
  144. package/docs/classes/MapEdge.html +0 -391
  145. package/docs/classes/MapGraph.html +0 -1583
  146. package/docs/classes/MapVertex.html +0 -356
  147. package/docs/classes/Matrix2D.html +0 -532
  148. package/docs/classes/MatrixNTI2D.html +0 -270
  149. package/docs/classes/MaxHeap.html +0 -671
  150. package/docs/classes/MaxPriorityQueue.html +0 -866
  151. package/docs/classes/MinHeap.html +0 -672
  152. package/docs/classes/MinPriorityQueue.html +0 -868
  153. package/docs/classes/Navigator.html +0 -343
  154. package/docs/classes/ObjectDeque.html +0 -527
  155. package/docs/classes/Pair.html +0 -202
  156. package/docs/classes/PriorityQueue.html +0 -790
  157. package/docs/classes/Queue.html +0 -521
  158. package/docs/classes/RBTree.html +0 -2024
  159. package/docs/classes/RBTreeNode.html +0 -431
  160. package/docs/classes/SegmentTree.html +0 -464
  161. package/docs/classes/SegmentTreeNode.html +0 -387
  162. package/docs/classes/SinglyLinkedList.html +0 -830
  163. package/docs/classes/SinglyLinkedListNode.html +0 -300
  164. package/docs/classes/SkipLinkedList.html +0 -202
  165. package/docs/classes/SplayTree.html +0 -202
  166. package/docs/classes/Stack.html +0 -398
  167. package/docs/classes/TreeMap.html +0 -202
  168. package/docs/classes/TreeMultiset.html +0 -2510
  169. package/docs/classes/TreeMultisetNode.html +0 -447
  170. package/docs/classes/TreeNode.html +0 -344
  171. package/docs/classes/TreeSet.html +0 -202
  172. package/docs/classes/Trie.html +0 -402
  173. package/docs/classes/TrieNode.html +0 -310
  174. package/docs/classes/TwoThreeTree.html +0 -202
  175. package/docs/classes/UndirectedEdge.html +0 -374
  176. package/docs/classes/UndirectedGraph.html +0 -1285
  177. package/docs/classes/UndirectedVertex.html +0 -284
  178. package/docs/classes/Vector2D.html +0 -835
  179. package/docs/enums/CP.html +0 -211
  180. package/docs/enums/FamilyPosition.html +0 -239
  181. package/docs/enums/LoopType.html +0 -212
  182. package/docs/enums/RBColor.html +0 -204
  183. package/docs/enums/TopologicalProperty.html +0 -211
  184. package/docs/functions/arrayRemove.html +0 -208
  185. package/docs/functions/isThunk.html +0 -186
  186. package/docs/functions/toThunk.html +0 -186
  187. package/docs/functions/trampoline.html +0 -186
  188. package/docs/functions/trampolineAsync.html +0 -186
  189. package/docs/functions/uuidV4.html +0 -181
  190. package/docs/interfaces/IAVLTree.html +0 -1245
  191. package/docs/interfaces/IAbstractBinaryTree.html +0 -1101
  192. package/docs/interfaces/IAbstractBinaryTreeNode.html +0 -335
  193. package/docs/interfaces/IAbstractGraph.html +0 -433
  194. package/docs/interfaces/IBST.html +0 -1245
  195. package/docs/interfaces/IDirectedGraph.html +0 -570
  196. package/docs/interfaces/IRBTree.html +0 -1247
  197. package/docs/interfaces/IUNDirectedGraph.html +0 -463
  198. package/docs/types/AVLTreeNodeNested.html +0 -182
  199. package/docs/types/AVLTreeOptions.html +0 -180
  200. package/docs/types/AbstractBinaryTreeNodeNested.html +0 -182
  201. package/docs/types/AbstractBinaryTreeNodeProperties.html +0 -182
  202. package/docs/types/AbstractBinaryTreeNodeProperty.html +0 -182
  203. package/docs/types/AbstractBinaryTreeOptions.html +0 -182
  204. package/docs/types/BSTComparator.html +0 -192
  205. package/docs/types/BSTNodeNested.html +0 -182
  206. package/docs/types/BSTOptions.html +0 -182
  207. package/docs/types/BinaryTreeDeletedResult.html +0 -189
  208. package/docs/types/BinaryTreeNodeId.html +0 -177
  209. package/docs/types/BinaryTreeNodeNested.html +0 -182
  210. package/docs/types/BinaryTreeNodePropertyName.html +0 -177
  211. package/docs/types/BinaryTreeOptions.html +0 -180
  212. package/docs/types/DFSOrderPattern.html +0 -177
  213. package/docs/types/DijkstraResult.html +0 -199
  214. package/docs/types/Direction.html +0 -177
  215. package/docs/types/DummyAny.html +0 -190
  216. package/docs/types/EdgeId.html +0 -177
  217. package/docs/types/HeapOptions.html +0 -198
  218. package/docs/types/IAVLTreeNode.html +0 -184
  219. package/docs/types/IBSTNode.html +0 -184
  220. package/docs/types/IBinaryTree.html +0 -182
  221. package/docs/types/IBinaryTreeNode.html +0 -184
  222. package/docs/types/IRBTreeNode.html +0 -184
  223. package/docs/types/ITreeMultiset.html +0 -182
  224. package/docs/types/ITreeMultisetNode.html +0 -184
  225. package/docs/types/KeyValueObject.html +0 -182
  226. package/docs/types/KeyValueObjectWithId.html +0 -184
  227. package/docs/types/MapGraphCoordinate.html +0 -177
  228. package/docs/types/NavigatorParams.html +0 -211
  229. package/docs/types/NodeOrPropertyName.html +0 -177
  230. package/docs/types/NonNumberNonObjectButDefined.html +0 -177
  231. package/docs/types/ObjectWithNonNumberId.html +0 -184
  232. package/docs/types/ObjectWithNumberId.html +0 -184
  233. package/docs/types/ObjectWithoutId.html +0 -177
  234. package/docs/types/PriorityQueueComparator.html +0 -197
  235. package/docs/types/PriorityQueueDFSOrderPattern.html +0 -177
  236. package/docs/types/PriorityQueueOptions.html +0 -191
  237. package/docs/types/RBTreeNodeNested.html +0 -182
  238. package/docs/types/RBTreeOptions.html +0 -180
  239. package/docs/types/RestrictValById.html +0 -177
  240. package/docs/types/SegmentTreeNodeVal.html +0 -177
  241. package/docs/types/SpecifyOptional.html +0 -184
  242. package/docs/types/Thunk.html +0 -185
  243. package/docs/types/ToThunkFn.html +0 -185
  244. package/docs/types/TopologicalStatus.html +0 -177
  245. package/docs/types/TreeMultisetNodeNested.html +0 -182
  246. package/docs/types/TreeMultisetOptions.html +0 -180
  247. package/docs/types/TrlAsyncFn.html +0 -190
  248. package/docs/types/TrlFn.html +0 -190
  249. package/docs/types/Turning.html +0 -177
  250. package/docs/types/VertexId.html +0 -177
  251. package/docs/variables/THUNK_SYMBOL.html +0 -177
  252. /package/{CODE-OF-CONDUCT.md → CODE_OF_CONDUCT.md} +0 -0
package/README.md CHANGED
@@ -8,29 +8,49 @@
8
8
  ![eslint](https://aleen42.github.io/badges/src/eslint.svg)
9
9
 
10
10
  ## Brief
11
- Data Structures of Javascript & TypeScript.
11
+
12
+ Data Structures of Javascript & TypeScript.
12
13
 
13
14
  ## Built-in classic algorithms
14
- DFS(Depth-First Search), DFSIterative, BFS(Breadth-First Search),
15
- morris, Bellman-Ford Algorithm, Dijkstra's Algorithm, Floyd-Warshall Algorithm,
16
- Tarjan's Algorithm.
15
+
16
+ DFS(Depth-First Search), DFSIterative, BFS(Breadth-First Search), morris, Bellman-Ford Algorithm, Dijkstra's Algorithm,
17
+ Floyd-Warshall Algorithm, Tarjan's Algorithm.
17
18
 
18
19
  ## Installation and Usage
20
+
19
21
  ### npm
22
+
20
23
  ```bash
21
24
  npm install data-structure-typed --save
22
25
  ```
26
+
23
27
  ### yarn
28
+
24
29
  ```bash
25
30
  yarn add data-structure-typed
26
31
  ```
32
+
27
33
  ### CDN
34
+
28
35
  ```html
36
+
29
37
  <script src="https://cdn.jsdelivr.net/npm/data-structure-typed/umd/bundle.min.js"></script>
30
38
  ```
39
+
31
40
  ```js
32
41
  const {AVLTree} = dataStructureTyped;
33
- const {Heap, MinHeap, SinglyLinkedList, Stack, AVLTreeNode, BST, Trie, DirectedGraph, DirectedVertex, TreeMultiset} = dataStructureTyped;
42
+ const {
43
+ Heap,
44
+ MinHeap,
45
+ SinglyLinkedList,
46
+ Stack,
47
+ AVLTreeNode,
48
+ BST,
49
+ Trie,
50
+ DirectedGraph,
51
+ DirectedVertex,
52
+ TreeMultiset
53
+ } = dataStructureTyped;
34
54
  ```
35
55
 
36
56
  ![](https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/examples/videos/webp_output/binary-tree-array-to-binary-tree.webp)
@@ -50,86 +70,93 @@ const {Heap, MinHeap, SinglyLinkedList, Stack, AVLTreeNode, BST, Trie, DirectedG
50
70
  <a href="https://github.com/zrwusa/vivid-algorithm" target="_blank">Examples Repository</a>
51
71
 
52
72
  ## Code Snippet
73
+
53
74
  ### Binary Search Tree (BST) snippet
75
+
54
76
  #### TS
77
+
55
78
  ```ts
56
- import {BST, BSTNode} from 'data-structure-typed';
57
-
58
- const bst = new BST();
59
- bst.add(11);
60
- bst.add(3);
61
- bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
62
- bst.size === 16; // true
63
- bst.has(6); // true
64
- const node6 = bst.get(6); // BSTNode
65
- bst.getHeight(6) === 2; // true
66
- bst.getHeight() === 5; // true
67
- bst.getDepth(6) === 3; // true
68
-
69
- bst.getLeftMost()?.id === 1; // true
70
-
71
- bst.remove(6);
72
- bst.get(6); // null
73
- bst.isAVLBalanced(); // true
74
- bst.BFS()[0] === 11; // true
75
-
76
- const objBST = new BST<BSTNode<{ id: number, keyA: number }>>();
77
- objBST.add(11, {id: 11, keyA: 11});
78
- objBST.add(3, {id: 3, keyA: 3});
79
-
80
- objBST.addMany([{id: 15, keyA: 15}, {id: 1, keyA: 1}, {id: 8, keyA: 8},
81
- {id: 13, keyA: 13}, {id: 16, keyA: 16}, {id: 2, keyA: 2},
82
- {id: 6, keyA: 6}, {id: 9, keyA: 9}, {id: 12, keyA: 12},
83
- {id: 14, keyA: 14}, {id: 4, keyA: 4}, {id: 7, keyA: 7},
84
- {id: 10, keyA: 10}, {id: 5, keyA: 5}]);
85
-
86
- objBST.remove(11);
79
+ import {BST, BSTNode} from 'data-structure-typed';
80
+
81
+ const bst = new BST();
82
+ bst.add(11);
83
+ bst.add(3);
84
+ bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
85
+ bst.size === 16; // true
86
+ bst.has(6); // true
87
+ const node6 = bst.get(6); // BSTNode
88
+ bst.getHeight(6) === 2; // true
89
+ bst.getHeight() === 5; // true
90
+ bst.getDepth(6) === 3; // true
91
+
92
+ bst.getLeftMost()?.id === 1; // true
93
+
94
+ bst.remove(6);
95
+ bst.get(6); // null
96
+ bst.isAVLBalanced(); // true
97
+ bst.BFS()[0] === 11; // true
98
+
99
+ const objBST = new BST<BSTNode<{ id: number, keyA: number }>>();
100
+ objBST.add(11, {id: 11, keyA: 11});
101
+ objBST.add(3, {id: 3, keyA: 3});
102
+
103
+ objBST.addMany([{id: 15, keyA: 15}, {id: 1, keyA: 1}, {id: 8, keyA: 8},
104
+ {id: 13, keyA: 13}, {id: 16, keyA: 16}, {id: 2, keyA: 2},
105
+ {id: 6, keyA: 6}, {id: 9, keyA: 9}, {id: 12, keyA: 12},
106
+ {id: 14, keyA: 14}, {id: 4, keyA: 4}, {id: 7, keyA: 7},
107
+ {id: 10, keyA: 10}, {id: 5, keyA: 5}]);
108
+
109
+ objBST.remove(11);
87
110
  ```
111
+
88
112
  #### JS
113
+
89
114
  ```js
90
- const {BST, BSTNode} = require('data-structure-typed');
91
-
92
- const bst = new BST();
93
- bst.add(11);
94
- bst.add(3);
95
- bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
96
- bst.size === 16; // true
97
- bst.has(6); // true
98
- const node6 = bst.get(6);
99
- bst.getHeight(6) === 2; // true
100
- bst.getHeight() === 5; // true
101
- bst.getDepth(6) === 3; // true
102
- const leftMost = bst.getLeftMost();
103
- leftMost?.id === 1; // true
104
- expect(leftMost?.id).toBe(1);
105
- bst.remove(6);
106
- bst.get(6); // null
107
- bst.isAVLBalanced(); // true or false
108
- const bfsIDs = bst.BFS();
109
- bfsIDs[0] === 11; // true
110
- expect(bfsIDs[0]).toBe(11);
111
-
112
- const objBST = new BST();
113
- objBST.add(11, {id: 11, keyA: 11});
114
- objBST.add(3, {id: 3, keyA: 3});
115
-
116
- objBST.addMany([{id: 15, keyA: 15}, {id: 1, keyA: 1}, {id: 8, keyA: 8},
117
- {id: 13, keyA: 13}, {id: 16, keyA: 16}, {id: 2, keyA: 2},
118
- {id: 6, keyA: 6}, {id: 9, keyA: 9}, {id: 12, keyA: 12},
119
- {id: 14, keyA: 14}, {id: 4, keyA: 4}, {id: 7, keyA: 7},
120
- {id: 10, keyA: 10}, {id: 5, keyA: 5}]);
121
-
122
- objBST.remove(11);
123
-
124
- const avlTree = new AVLTree();
125
- avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
126
- avlTree.isAVLBalanced(); // true
127
- avlTree.remove(10);
128
- avlTree.isAVLBalanced(); // true
115
+ const {BST, BSTNode} = require('data-structure-typed');
116
+
117
+ const bst = new BST();
118
+ bst.add(11);
119
+ bst.add(3);
120
+ bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
121
+ bst.size === 16; // true
122
+ bst.has(6); // true
123
+ const node6 = bst.get(6);
124
+ bst.getHeight(6) === 2; // true
125
+ bst.getHeight() === 5; // true
126
+ bst.getDepth(6) === 3; // true
127
+ const leftMost = bst.getLeftMost();
128
+ leftMost?.id === 1; // true
129
+ expect(leftMost?.id).toBe(1);
130
+ bst.remove(6);
131
+ bst.get(6); // null
132
+ bst.isAVLBalanced(); // true or false
133
+ const bfsIDs = bst.BFS();
134
+ bfsIDs[0] === 11; // true
135
+ expect(bfsIDs[0]).toBe(11);
136
+
137
+ const objBST = new BST();
138
+ objBST.add(11, {id: 11, keyA: 11});
139
+ objBST.add(3, {id: 3, keyA: 3});
140
+
141
+ objBST.addMany([{id: 15, keyA: 15}, {id: 1, keyA: 1}, {id: 8, keyA: 8},
142
+ {id: 13, keyA: 13}, {id: 16, keyA: 16}, {id: 2, keyA: 2},
143
+ {id: 6, keyA: 6}, {id: 9, keyA: 9}, {id: 12, keyA: 12},
144
+ {id: 14, keyA: 14}, {id: 4, keyA: 4}, {id: 7, keyA: 7},
145
+ {id: 10, keyA: 10}, {id: 5, keyA: 5}]);
146
+
147
+ objBST.remove(11);
148
+
149
+ const avlTree = new AVLTree();
150
+ avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
151
+ avlTree.isAVLBalanced(); // true
152
+ avlTree.remove(10);
153
+ avlTree.isAVLBalanced(); // true
129
154
  ```
130
155
 
131
156
  ### AVLTree snippet
157
+
132
158
  #### TS
159
+
133
160
  ```ts
134
161
  import {AVLTree} from 'data-structure-typed';
135
162
 
@@ -139,7 +166,9 @@ avlTree.isAVLBalanced(); // true
139
166
  avlTree.remove(10);
140
167
  avlTree.isAVLBalanced(); // true
141
168
  ```
169
+
142
170
  #### JS
171
+
143
172
  ```js
144
173
  const {AVLTree} = require('data-structure-typed');
145
174
 
@@ -151,7 +180,9 @@ avlTree.isAVLBalanced(); // true
151
180
  ```
152
181
 
153
182
  ### Directed Graph simple snippet
183
+
154
184
  #### TS or JS
185
+
155
186
  ```ts
156
187
  import {DirectedGraph} from 'data-structure-typed';
157
188
 
@@ -180,7 +211,9 @@ const topologicalOrderIds = graph.topologicalSort(); // ['A', 'B', 'C']
180
211
  ```
181
212
 
182
213
  ### Undirected Graph snippet
214
+
183
215
  #### TS or JS
216
+
184
217
  ```ts
185
218
  import {UndirectedGraph} from 'data-structure-typed';
186
219
 
@@ -198,6 +231,7 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D
198
231
  ```
199
232
 
200
233
  ## Data Structures
234
+
201
235
  <table>
202
236
  <thead>
203
237
  <tr>
@@ -374,11 +408,15 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D
374
408
  </table>
375
409
 
376
410
  ## Code design
377
- By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree -> TreeMultiset), you can seamlessly inherit the existing data structures to implement the customized ones you need. Object-oriented design stands as the optimal approach to data structure design.
411
+
412
+ By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree -> TreeMultiset), you can seamlessly
413
+ inherit the existing data structures to implement the customized ones you need. Object-oriented design stands as the
414
+ optimal approach to data structure design.
378
415
 
379
416
  ## Complexities
380
417
 
381
418
  ### performance of Big O
419
+
382
420
  <table>
383
421
  <thead>
384
422
  <tr>
@@ -443,6 +481,7 @@ By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree ->
443
481
  </table>
444
482
 
445
483
  ### Data Structure Complexity
484
+
446
485
  <table>
447
486
  <thead>
448
487
  <tr>
@@ -539,6 +578,7 @@ By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree ->
539
578
  </table>
540
579
 
541
580
  ### Sorting Complexity
581
+
542
582
  <table>
543
583
  <thead>
544
584
  <tr>
@@ -635,3 +675,253 @@ By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree ->
635
675
  </tr>
636
676
  </tbody>
637
677
  </table>
678
+
679
+
680
+ <table>
681
+ <tr>
682
+ <th>Data Structure</th>
683
+ <th>C++ STL</th>
684
+ <th>java.util</th>
685
+ <th>Python collections</th>
686
+ </tr>
687
+ <tr>
688
+ <td>Dynamic Array (ArrayList)</td>
689
+ <td>std::vector&lt;T&gt;</td>
690
+ <td>ArrayList&lt;E&gt;</td>
691
+ <td>list</td>
692
+ </tr>
693
+ <tr>
694
+ <td>Linked List</td>
695
+ <td>std::list&lt;T&gt;</td>
696
+ <td>LinkedList&lt;E&gt;</td>
697
+ <td>deque</td>
698
+ </tr>
699
+ <tr>
700
+ <td>Set</td>
701
+ <td>std::set&lt;T&gt;</td>
702
+ <td>HashSet&lt;E&gt;</td>
703
+ <td>set</td>
704
+ </tr>
705
+ <tr>
706
+ <td>Map</td>
707
+ <td>std::map&lt;K, V&gt;</td>
708
+ <td>HashMap&lt;K, V&gt;</td>
709
+ <td>dict</td>
710
+ </tr>
711
+ <tr>
712
+ <td>Stack</td>
713
+ <td>std::stack&lt;T&gt;</td>
714
+ <td>Stack&lt;E&gt;</td>
715
+ <td>N/A</td>
716
+ </tr>
717
+ <tr>
718
+ <td>Queue</td>
719
+ <td>std::queue&lt;T&gt;</td>
720
+ <td>LinkedList&lt;E&gt;</td>
721
+ <td>N/A</td>
722
+ </tr>
723
+ <tr>
724
+ <td>Priority Queue</td>
725
+ <td>std::priority_queue&lt;T&gt;</td>
726
+ <td>PriorityQueue&lt;E&gt;</td>
727
+ <td>N/A</td>
728
+ </tr>
729
+ <tr>
730
+ <td>Hash Table</td>
731
+ <td>N/A</td>
732
+ <td>N/A</td>
733
+ <td>defaultdict, Counter, etc.</td>
734
+ </tr>
735
+ <tr>
736
+ <td>Deque</td>
737
+ <td>std::deque&lt;T&gt;</td>
738
+ <td>N/A</td>
739
+ <td>N/A</td>
740
+ </tr>
741
+ <tr>
742
+ <td>Multiset</td>
743
+ <td>std::multiset&lt;T&gt;</td>
744
+ <td>N/A</td>
745
+ <td>N/A</td>
746
+ </tr>
747
+ <tr>
748
+ <td>Multimap</td>
749
+ <td>std::multimap&lt;K, V&gt;</td>
750
+ <td>N/A</td>
751
+ <td>N/A</td>
752
+ </tr>
753
+ <tr>
754
+ <td>Unordered Set</td>
755
+ <td>std::unordered_set&lt;T&gt;</td>
756
+ <td>HashSet&lt;E&gt;</td>
757
+ <td>N/A</td>
758
+ </tr>
759
+ <tr>
760
+ <td>Unordered Map</td>
761
+ <td>std::unordered_map&lt;K, V&gt;</td>
762
+ <td>HashMap&lt;K, V&gt;</td>
763
+ <td>N/A</td>
764
+ </tr>
765
+ <tr>
766
+ <td>Bitset</td>
767
+ <td>std::bitset&lt;N&gt;</td>
768
+ <td>N/A</td>
769
+ <td>N/A</td>
770
+ </tr>
771
+ <tr>
772
+ <td>Ordered Dictionary (OrderedDict)</td>
773
+ <td>N/A</td>
774
+ <td>N/A</td>
775
+ <td>OrderedDict</td>
776
+ </tr>
777
+ <tr>
778
+ <td>User-Defined Dictionary</td>
779
+ <td>N/A</td>
780
+ <td>N/A</td>
781
+ <td>UserDict</td>
782
+ </tr>
783
+ <tr>
784
+ <td>User-Defined List</td>
785
+ <td>N/A</td>
786
+ <td>N/A</td>
787
+ <td>UserList</td>
788
+ </tr>
789
+ <tr>
790
+ <td>User-Defined Set</td>
791
+ <td>N/A</td>
792
+ <td>N/A</td>
793
+ <td>UserSet</td>
794
+ </tr>
795
+ <tr>
796
+ <td>Double-Ended Queue (Deque)</td>
797
+ <td>std::deque&lt;T&gt;</td>
798
+ <td>N/A</td>
799
+ <td>N/A</td>
800
+ </tr>
801
+ <tr>
802
+ <td>Skip List</td>
803
+ <td>N/A</td>
804
+ <td>N/A</td>
805
+ <td>N/A</td>
806
+ </tr>
807
+ <tr>
808
+ <td>Circular Queue</td>
809
+ <td>N/A</td>
810
+ <td>N/A</td>
811
+ <td>N/A</td>
812
+ </tr>
813
+ <tr>
814
+ <td>Bit Array</td>
815
+ <td>N/A</td>
816
+ <td>N/A</td>
817
+ <td>N/A</td>
818
+ </tr>
819
+ <tr>
820
+ <td>Bloom Filter</td>
821
+ <td>N/A</td>
822
+ <td>N/A</td>
823
+ <td>N/A</td>
824
+ </tr>
825
+ <tr>
826
+ <td>Linked Hash Set</td>
827
+ <td>N/A</td>
828
+ <td>LinkedHashSet&lt;E&gt;</td>
829
+ <td>N/A</td>
830
+ </tr>
831
+ <tr>
832
+ <td>Linked Hash Map</td>
833
+ <td>N/A</td>
834
+ <td>LinkedHashMap&lt;K, V&gt;</td>
835
+ <td>N/A</td>
836
+ </tr>
837
+ <tr>
838
+ <td>Sorted Set</td>
839
+ <td>N/A</td>
840
+ <td>TreeSet&lt;E&gt;</td>
841
+ <td>N/A</td>
842
+ </tr>
843
+ <tr>
844
+ <td>Sorted Map</td>
845
+ <td>N/A</td>
846
+ <td>TreeMap&lt;K, V&gt;</td>
847
+ <td>N/A</td>
848
+ </tr>
849
+ <tr>
850
+ <td>Tree Set</td>
851
+ <td>N/A</td>
852
+ <td>N/A</td>
853
+ <td>N/A</td>
854
+ </tr>
855
+ <tr>
856
+ <td>Tree Map</td>
857
+ <td>N/A</td>
858
+ <td>N/A</td>
859
+ <td>N/A</td>
860
+ </tr>
861
+ <tr>
862
+ <td>Persistent Collections</td>
863
+ <td>N/A</td>
864
+ <td>N/A</td>
865
+ <td>N/A</td>
866
+ </tr>
867
+ <tr>
868
+ <td>std::unordered_multiset</td>
869
+ <td>std::unordered_multiset&lt;T&gt;</td>
870
+ <td>N/A</td>
871
+ <td>N/A</td>
872
+ </tr>
873
+ <tr>
874
+ <td>std::unordered_multimap</td>
875
+ <td>std::unordered_multimap&lt;K, V&gt;</td>
876
+ <td>N/A</td>
877
+ <td>N/A</td>
878
+ </tr>
879
+ <tr>
880
+ <td>N/A</td>
881
+ <td>TreeSet&lt;E&gt;</td>
882
+ <td>TreeSet&lt;E&gt;</td>
883
+ <td>N/A</td>
884
+ </tr>
885
+ <tr>
886
+ <td>N/A</td>
887
+ <td>TreeMap&lt;K, V&gt;</td>
888
+ <td>TreeMap&lt;K, V&gt;</td>
889
+ <td>N/A</td>
890
+ </tr>
891
+ <tr>
892
+ <td>N/A</td>
893
+ <td>LinkedBlockingQueue&lt;E&gt;</td>
894
+ <td>N/A</td>
895
+ <td>N/A</td>
896
+ </tr>
897
+ <tr>
898
+ <td>N/A</td>
899
+ <td>ConcurrentHashMap&lt;K, V&gt;</td>
900
+ <td>N/A</td>
901
+ <td>N/A</td>
902
+ </tr>
903
+ <tr>
904
+ <td>N/A</td>
905
+ <td>N/A</td>
906
+ <td>namedtuple</td>
907
+ <td>N/A</td>
908
+ </tr>
909
+ <tr>
910
+ <td>N/A</td>
911
+ <td>N/A</td>
912
+ <td>ChainMap</td>
913
+ <td>N/A</td>
914
+ </tr>
915
+ <tr>
916
+ <td>N/A</td>
917
+ <td>N/A</td>
918
+ <td>defaultdict</td>
919
+ <td>N/A</td>
920
+ </tr>
921
+ <tr>
922
+ <td>N/A</td>
923
+ <td>N/A</td>
924
+ <td>Counter</td>
925
+ <td>N/A</td>
926
+ </tr>
927
+ </table>