data-structure-typed 1.12.21 → 1.15.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 (42) hide show
  1. package/README.md +278 -179
  2. package/dist/data-structures/binary-tree/binary-tree.d.ts +46 -1
  3. package/dist/data-structures/binary-tree/binary-tree.js +67 -0
  4. package/dist/data-structures/binary-tree/segment-tree.d.ts +29 -0
  5. package/dist/data-structures/binary-tree/segment-tree.js +45 -0
  6. package/dist/data-structures/graph/abstract-graph.d.ts +40 -5
  7. package/dist/data-structures/graph/abstract-graph.js +47 -7
  8. package/dist/data-structures/graph/directed-graph.d.ts +8 -0
  9. package/dist/data-structures/graph/directed-graph.js +14 -2
  10. package/dist/data-structures/graph/undirected-graph.d.ts +10 -0
  11. package/dist/data-structures/graph/undirected-graph.js +23 -1
  12. package/dist/data-structures/hash/coordinate-map.d.ts +7 -1
  13. package/dist/data-structures/hash/coordinate-map.js +16 -0
  14. package/dist/data-structures/hash/coordinate-set.d.ts +7 -1
  15. package/dist/data-structures/hash/coordinate-set.js +16 -0
  16. package/dist/data-structures/heap/heap.d.ts +16 -0
  17. package/dist/data-structures/heap/heap.js +38 -0
  18. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +30 -7
  19. package/dist/data-structures/linked-list/doubly-linked-list.js +71 -4
  20. package/dist/data-structures/linked-list/singly-linked-list.d.ts +262 -328
  21. package/dist/data-structures/linked-list/singly-linked-list.js +258 -273
  22. package/dist/data-structures/priority-queue/priority-queue.d.ts +7 -1
  23. package/dist/data-structures/priority-queue/priority-queue.js +18 -2
  24. package/dist/data-structures/queue/deque.d.ts +18 -7
  25. package/dist/data-structures/queue/deque.js +50 -3
  26. package/dist/data-structures/types/abstract-graph.d.ts +2 -2
  27. package/package.json +2 -2
  28. package/src/data-structures/binary-tree/aa-tree.ts +1 -1
  29. package/src/data-structures/binary-tree/binary-tree.ts +84 -14
  30. package/src/data-structures/binary-tree/segment-tree.ts +45 -13
  31. package/src/data-structures/graph/abstract-graph.ts +58 -15
  32. package/src/data-structures/graph/directed-graph.ts +14 -5
  33. package/src/data-structures/graph/undirected-graph.ts +23 -6
  34. package/src/data-structures/hash/coordinate-map.ts +13 -1
  35. package/src/data-structures/hash/coordinate-set.ts +13 -1
  36. package/src/data-structures/heap/heap.ts +31 -0
  37. package/src/data-structures/linked-list/doubly-linked-list.ts +68 -11
  38. package/src/data-structures/linked-list/singly-linked-list.ts +312 -334
  39. package/src/data-structures/priority-queue/priority-queue.ts +15 -2
  40. package/src/data-structures/queue/deque.ts +38 -8
  41. package/src/data-structures/types/abstract-graph.ts +3 -3
  42. package/tests/unit/data-structures/graph/directed-graph.test.ts +431 -8
package/README.md CHANGED
@@ -1,4 +1,3 @@
1
- # data-structure-typed
2
1
 
3
2
  Javascript Data Structure, TypeScript Data Structure Library
4
3
 
@@ -15,15 +14,22 @@ yarn add data-structure-typed
15
14
  ```bash
16
15
  npm install data-structure-typed
17
16
  ```
18
- ## Online examples
19
17
 
20
- [Online Examples](https://data-structure-typed-examples.vercel.app)
18
+ ## Live Examples
21
19
 
22
- ## Examples Repository
20
+ [//]: # ([Live Examples](https://data-structure-typed-examples.vercel.app))
23
21
 
24
- [Example Repository](https://github.com/zrwusa/data-structure-typed-examples)
22
+ <a href="https://data-structure-typed-examples.vercel.app" target="_blank">Live Examples</a>
25
23
 
26
- ## api docs
24
+ ## Data Structures
25
+
26
+ Meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a
27
+ wide range of data structures:
28
+ Binary Tree, Binary Search Tree (BST), AVL Tree, Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed
29
+ Graph, Undirected Graph, Linked List, Singly Linked List, Doubly Linked List, Queue, Object Deque, Array Deque, Stack,
30
+ Hash, Coordinate Set, Coordinate Map, Heap, Priority Queue, Max Priority Queue, Min Priority Queue, Trie
31
+
32
+ ## API docs
27
33
 
28
34
  [//]: # ([api docs]&#40;https://data-structure-typed-docs.vercel.app/&#41;)
29
35
 
@@ -37,14 +43,16 @@ npm install data-structure-typed
37
43
  [//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/enums/LoopType.html"><span>Loop<wbr/>Type</span></a></li>)
38
44
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></li>
39
45
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTreeNode.html"><span>AVLTree<wbr/>Node</span></a></li>
40
- <li><a href="https://data-structure-typed-docs.vercel.app/classes/AaTree.html"><span>Aa<wbr/>Tree</span></a></li>
46
+
47
+ [//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/AaTree.html"><span>Aa<wbr/>Tree</span></a></li>)
41
48
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractEdge.html"><span>Abstract<wbr/>Edge</span></a></li>
42
49
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>Abstract<wbr/>Graph</span></a></li>
43
50
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractVertex.html"><span>Abstract<wbr/>Vertex</span></a></li>
44
51
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/ArrayDeque.html"><span>Array<wbr/>Deque</span></a></li>
45
52
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></li>
46
53
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/BSTNode.html"><span>BSTNode</span></a></li>
47
- <li><a href="https://data-structure-typed-docs.vercel.app/classes/BTree.html"><span>BTree</span></a></li>
54
+
55
+ [//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/BTree.html"><span>BTree</span></a></li>)
48
56
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>Binary<wbr/>Indexed<wbr/>Tree</span></a></li>
49
57
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary<wbr/>Tree</span></a></li>
50
58
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTreeNode.html"><span>Binary<wbr/>Tree<wbr/>Node</span></a></li>
@@ -68,200 +76,292 @@ npm install data-structure-typed
68
76
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/ObjectDeque.html"><span>Object<wbr/>Deque</span></a></li>
69
77
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>Priority<wbr/>Queue</span></a></li>
70
78
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></li>
71
- <li><a href="https://data-structure-typed-docs.vercel.app/classes/RBTree.html"><span>RBTree</span></a></li>
79
+
80
+ [//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/RBTree.html"><span>RBTree</span></a></li>)
72
81
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>Segment<wbr/>Tree</span></a></li>
73
82
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTreeNode.html"><span>Segment<wbr/>Tree<wbr/>Node</span></a></li>
74
83
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>Singly<wbr/>Linked<wbr/>List</span></a></li>
75
84
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedListNode.html"><span>Singly<wbr/>Linked<wbr/>List<wbr/>Node</span></a></li>
76
- <li><a href="https://data-structure-typed-docs.vercel.app/classes/SplayTree.html"><span>Splay<wbr/>Tree</span></a></li>
85
+
86
+ [//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/SplayTree.html"><span>Splay<wbr/>Tree</span></a></li>)
77
87
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></li>
78
88
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultiSet.html"><span>Tree<wbr/>Multi<wbr/>Set</span></a></li>
79
89
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></li>
80
90
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/TrieNode.html"><span>Trie<wbr/>Node</span></a></li>
81
- <li><a href="https://data-structure-typed-docs.vercel.app/classes/TwoThreeTree.html"><span>Two<wbr/>Three<wbr/>Tree</span></a></li>
91
+
92
+ [//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/TwoThreeTree.html"><span>Two<wbr/>Three<wbr/>Tree</span></a></li>)
82
93
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedEdge.html"><span>Undirected<wbr/>Edge</span></a></li>
83
94
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>Undirected<wbr/>Graph</span></a></li>
84
95
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedVertex.html"><span>Undirected<wbr/>Vertex</span></a></li>
85
96
  <li><a href="https://data-structure-typed-docs.vercel.app/classes/Vector2D.html"><span>Vector2D</span></a></li></ul></nav>
86
97
 
87
- ## data structures
98
+ [//]: # ([Examples Repository]&#40;https://github.com/zrwusa/data-structure-typed-examples&#41;)
99
+
100
+ <a href="https://github.com/zrwusa/data-structure-typed-examples" target="_blank">Examples Repository</a>
101
+
102
+
103
+ ## Complexities
104
+
105
+ ### performance of Big O
88
106
 
89
- Meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures:
90
- Binary Tree, Binary Search Tree (BST), AVL Tree, Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Linked List, Singly Linked List, Doubly Linked List, Queue, Object Deque, Array Deque, Stack, Hash, Coordinate Set, Coordinate Map, Heap, Priority Queue, Max Priority Queue, Min Priority Queue, Trie
91
107
  <table>
92
108
  <thead>
93
- <tr>
94
- <th>Data Structure</th>
95
- <th>Derived</th>
96
- <th>Basic Features</th>
97
- <th>Additional Features</th>
98
- </tr>
109
+ <tr>
110
+ <th>Big O Notation</th>
111
+ <th>Type</th>
112
+ <th>Computations for 10 elements</th>
113
+ <th>Computations for 100 elements</th>
114
+ <th>Computations for 1000 elements</th>
115
+ </tr>
99
116
  </thead>
100
-
101
117
  <tbody>
102
118
  <tr>
103
- <td>Binary Tree</td>
104
- <td>AVL Tree, Binary Search Tree, Tree Multiset</td>
105
- <td>put, has, get, remove, size, insertTo, insertMany, fill, getDepth, getHeight, getMinHeight, getPathToRoot, isBalanced </td>
106
- <td>getLeftMost, isBST, getSubTreeSizeAndCount, subTreeSum, subTreeAdd, BFS, DFS, DFSIterative, levelIterative, listLevels, getPredecessor, morris, </td>
107
- </tr>
108
-
109
- <tr>
110
- <td>AVL Tree</td>
111
- <td></td>
112
- <td>All the features inherited from Binary Tree, balanceFactor, updateHeight, balancePath, balanceLL, balanceLR, balanceRR, balanceRL</td>
113
- <td></td>
114
- </tr>
115
-
116
- <tr>
117
- <td>Binary Search Tree (BST)</td>
118
- <td></td>
119
- <td>All the features inherited from Binary Tree, lastKey</td>
120
- <td>All the features inherited from Binary Tree, lesserSum, allGreaterNodesAdd, balance, isAVLBalanced</td>
121
- </tr>
122
-
123
- <tr>
124
- <td>Tree Multiset</td>
125
- <td></td>
126
- <td>All the features inherited from Binary Tree</td>
127
- <td>All the features inherited from Binary Tree</td>
128
- </tr>
129
-
130
- <tr>
131
- <td>Segment Tree</td>
132
- <td></td>
133
- <td>build, updateNode, querySumByRange</td>
134
- <td></td>
135
- </tr>
136
-
137
- <tr>
138
- <td>Binary Indexed Tree</td>
139
- <td></td>
140
- <td>update, getPrefixSum, getRangeSum, BinaryIndexedTree.lowBit</td>
141
- <td></td>
142
- </tr>
143
- <tr>
144
- <td>Graph</td>
145
- <td>Directed Graph, Undirected Graph</td>
146
- <td>getVertex, getVertexId, containsVertex, vertexSet, addVertex, removeVertex, removeAllVertices, containsEdge, setEdgeWeight, getAllPathsBetween, getPathSumWeight, getMinCostBetween, getMinPathBetween, </td>
147
- <td>dijkstra, dijkstraWithoutHeap, bellmanFord, floyd, tarjan</td>
148
- </tr>
149
- <tr>
150
- <td>Directed Graph</td>
151
- <td></td>
152
- <td>All the features inherited from Graph, getEdge, addEdge, removeEdgeBetween, removeEdge, removeAllEdges, incomingEdgesOf, outgoingEdgesOf, degreeOf, inDegreeOf, outDegreeOf, edgesOf, getEdgeSrc, getEdgeDest, getDestinations, edgeSet, getNeighbors, getEndsOfEdge</td>
153
- <td>All the features inherited from Graph, topologicalSort</td>
154
- </tr>
155
- <tr>
156
- <td>Undirected Graph</td>
157
- <td></td>
158
- <td>All the features inherited from Graph, getEdge, addEdge, removeEdgeBetween, removeEdge, degreeOf, edgesOf, edgeSet, getEdgesOf, getNeighbors, getEndsOfEdge</td>
159
- <td>All the features inherited from Graph</td>
160
- </tr>
161
- <tr>
162
- <td>Singly Linked List</td>
163
- <td></td>
164
- <td>length, head, tail, size, get, getNode, findNodeIndex, findNode, find, findIndex, append, push, prepend, insertAt, removeNode, removeAt, insertBefore, sort, insertAfter, shift, pop, merge, clear, slice, reverse, forEach, map, filter, reduce, toArray, toString</td>
165
- <td></td>
166
-
167
- </tr>
168
- <tr>
169
- <td>Hash</td>
170
- <td>CoordinateSet, CoordinateMap</td>
171
- <td></td>
172
- <td></td>
173
- </tr>
174
- <tr>
175
- <td>CoordinateSet</td>
176
- <td></td>
177
- <td>has, set, get, delete</td>
178
- <td></td>
179
- </tr>
180
- <tr>
181
- <td>CoordinateMap</td>
182
- <td></td>
183
- <td>has, add, delete</td>
184
- <td></td>
185
- </tr>
186
- <tr>
187
- <td>Heap</td>
188
- <td></td>
189
- <td></td>
190
- </tr>
191
-
192
-
193
- <tr>
194
- <td>Doubly Linked List</td>
195
- <td></td>
196
- <td>size, offerFirst, offerLast, peekFirst, peekLast, pollFirst, pollLast, get, isEmpty, insert, remove, </td>
197
- <td></td>
198
- </tr>
199
-
200
- [//]: # ( <tr>)
201
-
202
- [//]: # ( <td>Matrix</td>)
203
-
204
- [//]: # ( <td></td>)
205
-
206
- [//]: # ( <td></td>)
207
-
208
- [//]: # ( <td></td>)
209
-
210
- [//]: # ( </tr>)
211
-
212
- <tr>
213
- <td>Priority Queue</td>
214
- <td>Max Priority Queue, Min Priority Queue</td>
215
- <td>offer, peek, poll, leaf, isEmpty, clear, toArray, clone</td>
216
- <td>isValid, sort, DFS</td>
217
- </tr>
218
- <tr>
219
- <td>Max Priority Queue</td>
220
- <td></td>
221
- <td>All the features inherited from Priority Queue</td>
222
- <td>All the features inherited from Priority Queue</td>
223
- </tr>
224
- <tr>
225
- <td>Min Priority Queue</td>
226
- <td></td>
227
- <td>All the features inherited from Priority Queue</td>
228
- <td>All the features inherited from Priority Queue</td>
229
- </tr>
230
- <tr>
231
- <td>Queue</td>
232
- <td>Queue, Dequeue</td>
233
- <td>offer, poll, peek, peekLast, size, isEmpty, toArray, clear, clone, Queue.fromArray</td>
234
- <td></td>
235
- </tr>
236
- <tr>
237
- <td>ObjectDeque</td>
238
- <td></td>
239
- <td>size, offerFirst, offerLast, pollFirst, peekFirst, pollLast, peekLast, get, isEmpty</td>
240
- <td></td>
241
- </tr>
242
- <tr>
243
- <td>ArrayDeque</td>
244
- <td></td>
245
- <td>offerLast, pollLast, pollFirst, offerFirst, peekFirst, peekLast, get, set, insert, remove, isEmpty</td>
246
- <td></td>
247
- </tr>
248
- <tr>
249
- <td>Stack</td>
250
- <td></td>
251
- <td>isEmpty, size, peek, push, pop, toArray, clear, clone, Stack.fromArray</td>
252
- <td></td>
253
- </tr>
254
- <tr>
255
- <td>Trie</td>
256
- <td></td>
257
- <td>put, has, remove, isAbsPrefix, isPrefix, getAll</td>
258
- <td></td>
259
- </tr>
119
+ <td><strong>O(1)</strong></td>
120
+ <td>Constant</td>
121
+ <td>1</td>
122
+ <td>1</td>
123
+ <td>1</td>
124
+ </tr>
125
+ <tr>
126
+ <td><strong>O(log N)</strong></td>
127
+ <td>Logarithmic</td>
128
+ <td>3</td>
129
+ <td>6</td>
130
+ <td>9</td>
131
+ </tr>
132
+ <tr>
133
+ <td><strong>O(N)</strong></td>
134
+ <td>Linear</td>
135
+ <td>10</td>
136
+ <td>100</td>
137
+ <td>1000</td>
138
+ </tr>
139
+ <tr>
140
+ <td><strong>O(N log N)</strong></td>
141
+ <td>n log(n)</td>
142
+ <td>30</td>
143
+ <td>600</td>
144
+ <td>9000</td>
145
+ </tr>
146
+ <tr>
147
+ <td><strong>O(N^2)</strong></td>
148
+ <td>Quadratic</td>
149
+ <td>100</td>
150
+ <td>10000</td>
151
+ <td>1000000</td>
152
+ </tr>
153
+ <tr>
154
+ <td><strong>O(2^N)</strong></td>
155
+ <td>Exponential</td>
156
+ <td>1024</td>
157
+ <td>1.26e+29</td>
158
+ <td>1.07e+301</td>
159
+ </tr>
160
+ <tr>
161
+ <td><strong>O(N!)</strong></td>
162
+ <td>Factorial</td>
163
+ <td>3628800</td>
164
+ <td>9.3e+157</td>
165
+ <td>4.02e+2567</td>
166
+ </tr>
260
167
  </tbody>
168
+ </table>
169
+
170
+ ### Data Structure Complexity
261
171
 
172
+ <table>
173
+ <thead>
174
+ <tr>
175
+ <th>Data Structure</th>
176
+ <th>Access</th>
177
+ <th>Search</th>
178
+ <th>Insertion</th>
179
+ <th>Deletion</th>
180
+ <th>Comments</th>
181
+ </tr>
182
+ </thead>
183
+ <tbody>
184
+ <tr>
185
+ <td><strong>Array</strong></td>
186
+ <td>1</td>
187
+ <td>n</td>
188
+ <td>n</td>
189
+ <td>n</td>
190
+ <td></td>
191
+ </tr>
192
+ <tr>
193
+ <td><strong>Stack</strong></td>
194
+ <td>n</td>
195
+ <td>n</td>
196
+ <td>1</td>
197
+ <td>1</td>
198
+ <td></td>
199
+ </tr>
200
+ <tr>
201
+ <td><strong>Queue</strong></td>
202
+ <td>n</td>
203
+ <td>n</td>
204
+ <td>1</td>
205
+ <td>1</td>
206
+ <td></td>
207
+ </tr>
208
+ <tr>
209
+ <td><strong>Linked List</strong></td>
210
+ <td>n</td>
211
+ <td>n</td>
212
+ <td>1</td>
213
+ <td>n</td>
214
+ <td></td>
215
+ </tr>
216
+ <tr>
217
+ <td><strong>Hash Table</strong></td>
218
+ <td>-</td>
219
+ <td>n</td>
220
+ <td>n</td>
221
+ <td>n</td>
222
+ <td>In case of perfect hash function costs would be O(1)</td>
223
+ </tr>
224
+ <tr>
225
+ <td><strong>Binary Search Tree</strong></td>
226
+ <td>n</td>
227
+ <td>n</td>
228
+ <td>n</td>
229
+ <td>n</td>
230
+ <td>In case of balanced tree costs would be O(log(n))</td>
231
+ </tr>
232
+ <tr>
233
+ <td><strong>B-Tree</strong></td>
234
+ <td>log(n)</td>
235
+ <td>log(n)</td>
236
+ <td>log(n)</td>
237
+ <td>log(n)</td>
238
+ <td></td>
239
+ </tr>
240
+ <tr>
241
+ <td><strong>Red-Black Tree</strong></td>
242
+ <td>log(n)</td>
243
+ <td>log(n)</td>
244
+ <td>log(n)</td>
245
+ <td>log(n)</td>
246
+ <td></td>
247
+ </tr>
248
+ <tr>
249
+ <td><strong>AVL Tree</strong></td>
250
+ <td>log(n)</td>
251
+ <td>log(n)</td>
252
+ <td>log(n)</td>
253
+ <td>log(n)</td>
254
+ <td></td>
255
+ </tr>
256
+ <tr>
257
+ <td><strong>Bloom Filter</strong></td>
258
+ <td>-</td>
259
+ <td>1</td>
260
+ <td>1</td>
261
+ <td>-</td>
262
+ <td>False positives are possible while searching</td>
263
+ </tr>
264
+ </tbody>
262
265
  </table>
263
266
 
267
+ ### Sorting Complexity
264
268
 
269
+ <table>
270
+ <thead>
271
+ <tr>
272
+ <th>Name</th>
273
+ <th>Best</th>
274
+ <th>Average</th>
275
+ <th>Worst</th>
276
+ <th>Memory</th>
277
+ <th>Stable</th>
278
+ <th>Comments</th>
279
+ </tr>
280
+ </thead>
281
+ <tbody>
282
+ <tr>
283
+ <td><strong>Bubble sort</strong></td>
284
+ <td>n</td>
285
+ <td>n<sup>2</sup></td>
286
+ <td>n<sup>2</sup></td>
287
+ <td>1</td>
288
+ <td>Yes</td>
289
+ <td></td>
290
+ </tr>
291
+ <tr>
292
+ <td><strong>Insertion sort</strong></td>
293
+ <td>n</td>
294
+ <td>n<sup>2</sup></td>
295
+ <td>n<sup>2</sup></td>
296
+ <td>1</td>
297
+ <td>Yes</td>
298
+ <td></td>
299
+ </tr>
300
+ <tr>
301
+ <td><strong>Selection sort</strong></td>
302
+ <td>n<sup>2</sup></td>
303
+ <td>n<sup>2</sup></td>
304
+ <td>n<sup>2</sup></td>
305
+ <td>1</td>
306
+ <td>No</td>
307
+ <td></td>
308
+ </tr>
309
+ <tr>
310
+ <td><strong>Heap sort</strong></td>
311
+ <td>n&nbsp;log(n)</td>
312
+ <td>n&nbsp;log(n)</td>
313
+ <td>n&nbsp;log(n)</td>
314
+ <td>1</td>
315
+ <td>No</td>
316
+ <td></td>
317
+ </tr>
318
+ <tr>
319
+ <td><strong>Merge sort</strong></td>
320
+ <td>n&nbsp;log(n)</td>
321
+ <td>n&nbsp;log(n)</td>
322
+ <td>n&nbsp;log(n)</td>
323
+ <td>n</td>
324
+ <td>Yes</td>
325
+ <td></td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>Quick sort</strong></td>
329
+ <td>n&nbsp;log(n)</td>
330
+ <td>n&nbsp;log(n)</td>
331
+ <td>n<sup>2</sup></td>
332
+ <td>log(n)</td>
333
+ <td>No</td>
334
+ <td>Quicksort is usually done in-place with O(log(n)) stack space</td>
335
+ </tr>
336
+ <tr>
337
+ <td><strong>Shell sort</strong></td>
338
+ <td>n&nbsp;log(n)</td>
339
+ <td>depends on gap sequence</td>
340
+ <td>n&nbsp;(log(n))<sup>2</sup></td>
341
+ <td>1</td>
342
+ <td>No</td>
343
+ <td></td>
344
+ </tr>
345
+ <tr>
346
+ <td><strong>Counting sort</strong></td>
347
+ <td>n + r</td>
348
+ <td>n + r</td>
349
+ <td>n + r</td>
350
+ <td>n + r</td>
351
+ <td>Yes</td>
352
+ <td>r - biggest number in array</td>
353
+ </tr>
354
+ <tr>
355
+ <td><strong>Radix sort</strong></td>
356
+ <td>n * k</td>
357
+ <td>n * k</td>
358
+ <td>n * k</td>
359
+ <td>n + k</td>
360
+ <td>Yes</td>
361
+ <td>k - length of longest key</td>
362
+ </tr>
363
+ </tbody>
364
+ </table>
265
365
 
266
366
 
267
367
  ![complexities](src/assets/complexities-diff.jpg)
@@ -272,7 +372,6 @@ Binary Tree, Binary Search Tree (BST), AVL Tree, Tree Multiset, Segment Tree, Bi
272
372
 
273
373
  ![](src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif)
274
374
 
275
-
276
375
  ![](src/data-structures/graph/diagrams/tarjan.webp)
277
376
 
278
377
  ![](src/data-structures/graph/diagrams/adjacency-list.jpg)
@@ -22,31 +22,63 @@ export declare enum LoopType {
22
22
  recursive = 2
23
23
  }
24
24
  export declare class BinaryTreeNode<T> {
25
- constructor(id: BinaryTreeNodeId, val: T, count?: number);
26
25
  protected _id: BinaryTreeNodeId;
27
26
  get id(): BinaryTreeNodeId;
27
+ /**
28
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
29
+ */
30
+ getId(): BinaryTreeNodeId;
28
31
  set id(v: BinaryTreeNodeId);
29
32
  protected _val: T;
30
33
  get val(): T;
34
+ /**
35
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
36
+ */
37
+ getVal(): T;
31
38
  set val(v: T);
32
39
  protected _left?: BinaryTreeNode<T> | null;
33
40
  get left(): BinaryTreeNode<T> | null | undefined;
41
+ /**
42
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
43
+ */
44
+ getLeft(): BinaryTreeNode<T> | null | undefined;
34
45
  set left(v: BinaryTreeNode<T> | null | undefined);
35
46
  protected _right?: BinaryTreeNode<T> | null;
36
47
  get right(): BinaryTreeNode<T> | null | undefined;
48
+ /**
49
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
50
+ */
51
+ getRight(): BinaryTreeNode<T> | null | undefined;
37
52
  set right(v: BinaryTreeNode<T> | null | undefined);
38
53
  protected _parent: BinaryTreeNode<T> | null | undefined;
39
54
  get parent(): BinaryTreeNode<T> | null | undefined;
55
+ /**
56
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
57
+ */
58
+ getParent(): BinaryTreeNode<T> | null | undefined;
40
59
  set parent(v: BinaryTreeNode<T> | null | undefined);
41
60
  protected _familyPosition: FamilyPosition;
42
61
  get familyPosition(): FamilyPosition;
62
+ /**
63
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
64
+ */
65
+ getFamilyPosition(): FamilyPosition;
43
66
  set familyPosition(v: FamilyPosition);
44
67
  protected _count: number;
45
68
  get count(): number;
69
+ /**
70
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
71
+ */
72
+ getCount(): number;
46
73
  set count(v: number);
47
74
  protected _height: number;
48
75
  get height(): number;
76
+ /**
77
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
78
+ */
79
+ getHeight(): number;
49
80
  set height(v: number);
81
+ constructor(id: BinaryTreeNodeId, val: T, count?: number);
50
82
  swapLocation(swapNode: BinaryTreeNode<T>): BinaryTreeNode<T>;
51
83
  clone(): BinaryTreeNode<T>;
52
84
  }
@@ -72,12 +104,25 @@ export declare class BinaryTree<T> {
72
104
  });
73
105
  protected _root: BinaryTreeNode<T> | null;
74
106
  get root(): BinaryTreeNode<T> | null;
107
+ /**
108
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Getters (using the same name as the property) while utilizing separate method names for Setters.
109
+ * @returns The method is returning either a BinaryTreeNode object of type T or null.
110
+ */
111
+ getRoot(): BinaryTreeNode<T> | null;
75
112
  protected set root(v: BinaryTreeNode<T> | null);
76
113
  protected _size: number;
77
114
  get size(): number;
115
+ /**
116
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
117
+ */
118
+ getSize(): number;
78
119
  protected set size(v: number);
79
120
  protected _count: number;
80
121
  get count(): number;
122
+ /**
123
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
124
+ */
125
+ getCount(): number;
81
126
  protected set count(v: number);
82
127
  /**
83
128
  * The function creates a new binary tree node with the given id, value, and count, or returns null if the value is