min-heap-typed 1.51.2 → 1.51.4
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.
- package/README.md +5 -409
- package/dist/data-structures/binary-tree/binary-tree.js +2 -2
- package/dist/data-structures/binary-tree/bst.js +1 -1
- package/dist/data-structures/index.d.ts +1 -1
- package/dist/data-structures/index.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/number.js +11 -0
- package/package.json +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +2 -2
- package/src/data-structures/binary-tree/bst.ts +1 -1
- package/src/data-structures/index.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/number.ts +9 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|

|
|
3
3
|

|
|
4
4
|

|
|
5
|
-

|
|
6
6
|

|
|
7
7
|

|
|
8
8
|
|
|
@@ -106,132 +106,14 @@ yarn add min-heap-typed
|
|
|
106
106
|
</tr>
|
|
107
107
|
</thead>
|
|
108
108
|
<tbody>
|
|
109
|
-
|
|
110
|
-
<td>Binary Tree</td>
|
|
111
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
112
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
113
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary Tree</span></a></td>
|
|
114
|
-
</tr>
|
|
115
|
-
<tr>
|
|
116
|
-
<td>Binary Search Tree (BST)</td>
|
|
117
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
118
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
119
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></td>
|
|
120
|
-
</tr>
|
|
121
|
-
<tr>
|
|
122
|
-
<td>AVL Tree</td>
|
|
123
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
124
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
125
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></td>
|
|
126
|
-
</tr>
|
|
127
|
-
<tr>
|
|
128
|
-
<td>Red Black Tree</td>
|
|
129
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
130
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
131
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/RedBlackTree.html"><span>RedBlackTree</span></a></td>
|
|
132
|
-
</tr>
|
|
133
|
-
<tr>
|
|
134
|
-
<td>Tree Multiset</td>
|
|
135
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
136
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
137
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultimap.html"><span>TreeMultimap</span></a></td>
|
|
138
|
-
</tr>
|
|
139
|
-
<tr>
|
|
140
|
-
<td>Segment Tree</td>
|
|
141
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
142
|
-
<td></td>
|
|
143
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>SegmentTree</span></a></td>
|
|
144
|
-
</tr>
|
|
145
|
-
<tr>
|
|
146
|
-
<td>Binary Indexed Tree</td>
|
|
147
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
148
|
-
<td></td>
|
|
149
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>BinaryIndexedTree</span></a></td>
|
|
150
|
-
</tr>
|
|
109
|
+
|
|
151
110
|
<tr>
|
|
152
111
|
<td>Heap</td>
|
|
153
112
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
154
113
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
155
114
|
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html"><span>Heap</span></a></td>
|
|
156
115
|
</tr>
|
|
157
|
-
|
|
158
|
-
<td>Priority Queue</td>
|
|
159
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
160
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
161
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>PriorityQueue</span></a></td>
|
|
162
|
-
</tr>
|
|
163
|
-
<tr>
|
|
164
|
-
<td>Max Priority Queue</td>
|
|
165
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
166
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
167
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html"><span>MaxPriorityQueue</span></a></td>
|
|
168
|
-
</tr>
|
|
169
|
-
<tr>
|
|
170
|
-
<td>Min Priority Queue</td>
|
|
171
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
172
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
173
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html"><span>MinPriorityQueue</span></a></td>
|
|
174
|
-
</tr>
|
|
175
|
-
<tr>
|
|
176
|
-
<td>Trie</td>
|
|
177
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
178
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
179
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></td>
|
|
180
|
-
</tr>
|
|
181
|
-
<tr>
|
|
182
|
-
<td>Graph</td>
|
|
183
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
184
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
185
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>AbstractGraph</span></a></td>
|
|
186
|
-
</tr>
|
|
187
|
-
<tr>
|
|
188
|
-
<td>Directed Graph</td>
|
|
189
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
190
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
191
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html"><span>DirectedGraph</span></a></td>
|
|
192
|
-
</tr>
|
|
193
|
-
<tr>
|
|
194
|
-
<td>Undirected Graph</td>
|
|
195
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
196
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
197
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>UndirectedGraph</span></a></td>
|
|
198
|
-
</tr>
|
|
199
|
-
<tr>
|
|
200
|
-
<td>Queue</td>
|
|
201
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
202
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
203
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></td>
|
|
204
|
-
</tr>
|
|
205
|
-
<tr>
|
|
206
|
-
<td>Deque</td>
|
|
207
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
208
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
209
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html"><span>Deque</span></a></td>
|
|
210
|
-
</tr>
|
|
211
|
-
<tr>
|
|
212
|
-
<td>Linked List</td>
|
|
213
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
214
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
215
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
216
|
-
</tr>
|
|
217
|
-
<tr>
|
|
218
|
-
<td>Singly Linked List</td>
|
|
219
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
220
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
221
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
222
|
-
</tr>
|
|
223
|
-
<tr>
|
|
224
|
-
<td>Doubly Linked List</td>
|
|
225
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
226
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
227
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html"><span>DoublyLinkedList</span></a></td>
|
|
228
|
-
</tr>
|
|
229
|
-
<tr>
|
|
230
|
-
<td>Stack</td>
|
|
231
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
232
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
233
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></td>
|
|
234
|
-
</tr>
|
|
116
|
+
|
|
235
117
|
</tbody>
|
|
236
118
|
</table>
|
|
237
119
|
|
|
@@ -253,162 +135,7 @@ yarn add min-heap-typed
|
|
|
253
135
|
<td>PriorityQueue<E></td>
|
|
254
136
|
<td>heapq</td>
|
|
255
137
|
</tr>
|
|
256
|
-
|
|
257
|
-
<td>Deque<E></td>
|
|
258
|
-
<td>deque<T></td>
|
|
259
|
-
<td>ArrayDeque<E></td>
|
|
260
|
-
<td>deque</td>
|
|
261
|
-
</tr>
|
|
262
|
-
<tr>
|
|
263
|
-
<td>Queue<E></td>
|
|
264
|
-
<td>queue<T></td>
|
|
265
|
-
<td>Queue<E></td>
|
|
266
|
-
<td>-</td>
|
|
267
|
-
</tr>
|
|
268
|
-
<tr>
|
|
269
|
-
<td>HashMap<K, V></td>
|
|
270
|
-
<td>unordered_map<K, V></td>
|
|
271
|
-
<td>HashMap<K, V></td>
|
|
272
|
-
<td>defaultdict</td>
|
|
273
|
-
</tr>
|
|
274
|
-
<tr>
|
|
275
|
-
<td>DoublyLinkedList<E></td>
|
|
276
|
-
<td>list<T></td>
|
|
277
|
-
<td>LinkedList<E></td>
|
|
278
|
-
<td>-</td>
|
|
279
|
-
</tr>
|
|
280
|
-
<tr>
|
|
281
|
-
<td>SinglyLinkedList<E></td>
|
|
282
|
-
<td>-</td>
|
|
283
|
-
<td>-</td>
|
|
284
|
-
<td>-</td>
|
|
285
|
-
</tr>
|
|
286
|
-
<tr>
|
|
287
|
-
<td>BinaryTree<K, V></td>
|
|
288
|
-
<td>-</td>
|
|
289
|
-
<td>-</td>
|
|
290
|
-
<td>-</td>
|
|
291
|
-
</tr>
|
|
292
|
-
<tr>
|
|
293
|
-
<td>BST<K, V></td>
|
|
294
|
-
<td>-</td>
|
|
295
|
-
<td>-</td>
|
|
296
|
-
<td>-</td>
|
|
297
|
-
</tr>
|
|
298
|
-
<tr>
|
|
299
|
-
<td>RedBlackTree<E></td>
|
|
300
|
-
<td>set<T></td>
|
|
301
|
-
<td>TreeSet<E></td>
|
|
302
|
-
<td>-</td>
|
|
303
|
-
</tr>
|
|
304
|
-
<tr>
|
|
305
|
-
<td>RedBlackTree<K, V></td>
|
|
306
|
-
<td>map<K, V></td>
|
|
307
|
-
<td>TreeMap<K, V></td>
|
|
308
|
-
<td>-</td>
|
|
309
|
-
</tr>
|
|
310
|
-
<tr>
|
|
311
|
-
<td>TreeMultimap<K, V></td>
|
|
312
|
-
<td>multimap<K, V></td>
|
|
313
|
-
<td>-</td>
|
|
314
|
-
<td>-</td>
|
|
315
|
-
</tr>
|
|
316
|
-
<tr>
|
|
317
|
-
<td>-</td>
|
|
318
|
-
<td>multiset<T></td>
|
|
319
|
-
<td>-</td>
|
|
320
|
-
<td>-</td>
|
|
321
|
-
</tr>
|
|
322
|
-
<tr>
|
|
323
|
-
<td>Trie</td>
|
|
324
|
-
<td>-</td>
|
|
325
|
-
<td>-</td>
|
|
326
|
-
<td>-</td>
|
|
327
|
-
</tr>
|
|
328
|
-
<tr>
|
|
329
|
-
<td>DirectedGraph<V, E></td>
|
|
330
|
-
<td>-</td>
|
|
331
|
-
<td>-</td>
|
|
332
|
-
<td>-</td>
|
|
333
|
-
</tr>
|
|
334
|
-
<tr>
|
|
335
|
-
<td>UndirectedGraph<V, E></td>
|
|
336
|
-
<td>-</td>
|
|
337
|
-
<td>-</td>
|
|
338
|
-
<td>-</td>
|
|
339
|
-
</tr>
|
|
340
|
-
<tr>
|
|
341
|
-
<td>PriorityQueue<E></td>
|
|
342
|
-
<td>priority_queue<T></td>
|
|
343
|
-
<td>PriorityQueue<E></td>
|
|
344
|
-
<td>-</td>
|
|
345
|
-
</tr>
|
|
346
|
-
<tr>
|
|
347
|
-
<td>Array<E></td>
|
|
348
|
-
<td>vector<T></td>
|
|
349
|
-
<td>ArrayList<E></td>
|
|
350
|
-
<td>list</td>
|
|
351
|
-
</tr>
|
|
352
|
-
<tr>
|
|
353
|
-
<td>Stack<E></td>
|
|
354
|
-
<td>stack<T></td>
|
|
355
|
-
<td>Stack<E></td>
|
|
356
|
-
<td>-</td>
|
|
357
|
-
</tr>
|
|
358
|
-
<tr>
|
|
359
|
-
<td>Set<E></td>
|
|
360
|
-
<td>-</td>
|
|
361
|
-
<td>HashSet<E></td>
|
|
362
|
-
<td>set</td>
|
|
363
|
-
</tr>
|
|
364
|
-
<tr>
|
|
365
|
-
<td>Map<K, V></td>
|
|
366
|
-
<td>-</td>
|
|
367
|
-
<td>HashMap<K, V></td>
|
|
368
|
-
<td>dict</td>
|
|
369
|
-
</tr>
|
|
370
|
-
<tr>
|
|
371
|
-
<td>-</td>
|
|
372
|
-
<td>unordered_set<T></td>
|
|
373
|
-
<td>HashSet<E></td>
|
|
374
|
-
<td>-</td>
|
|
375
|
-
</tr>
|
|
376
|
-
<tr>
|
|
377
|
-
<td>Map<K, V></td>
|
|
378
|
-
<td>-</td>
|
|
379
|
-
<td>-</td>
|
|
380
|
-
<td>OrderedDict</td>
|
|
381
|
-
</tr>
|
|
382
|
-
<tr>
|
|
383
|
-
<td>-</td>
|
|
384
|
-
<td>unordered_multiset</td>
|
|
385
|
-
<td>-</td>
|
|
386
|
-
<td>Counter</td>
|
|
387
|
-
</tr>
|
|
388
|
-
<tr>
|
|
389
|
-
<td>-</td>
|
|
390
|
-
<td>-</td>
|
|
391
|
-
<td>LinkedHashSet<E></td>
|
|
392
|
-
<td>-</td>
|
|
393
|
-
</tr>
|
|
394
|
-
<tr>
|
|
395
|
-
<td>HashMap<K, V></td>
|
|
396
|
-
<td>-</td>
|
|
397
|
-
<td>LinkedHashMap<K, V></td>
|
|
398
|
-
<td>-</td>
|
|
399
|
-
</tr>
|
|
400
|
-
<tr>
|
|
401
|
-
<td>-</td>
|
|
402
|
-
<td>unordered_multimap<K, V></td>
|
|
403
|
-
<td>-</td>
|
|
404
|
-
<td>-</td>
|
|
405
|
-
</tr>
|
|
406
|
-
<tr>
|
|
407
|
-
<td>-</td>
|
|
408
|
-
<td>bitset<N></td>
|
|
409
|
-
<td>-</td>
|
|
410
|
-
<td>-</td>
|
|
411
|
-
</tr>
|
|
138
|
+
|
|
412
139
|
</tbody>
|
|
413
140
|
</table>
|
|
414
141
|
|
|
@@ -416,53 +143,8 @@ yarn add min-heap-typed
|
|
|
416
143
|
|
|
417
144
|
[//]: # (No deletion!!! Start of Replace Section)
|
|
418
145
|
<div class="json-to-html-collapse clearfix 0">
|
|
419
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
|
|
420
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 add randomly</td><td>31.32</td><td>31.93</td><td>3.67e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>70.90</td><td>14.10</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>40.58</td><td>24.64</td><td>4.87e-4</td></tr><tr><td>10,000 get</td><td>27.31</td><td>36.62</td><td>2.00e-4</td></tr></table></div>
|
|
421
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
422
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>binary-tree</span></div>
|
|
423
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000 add randomly</td><td>12.35</td><td>80.99</td><td>7.17e-5</td></tr><tr><td>1,000 add & delete randomly</td><td>15.98</td><td>62.58</td><td>7.98e-4</td></tr><tr><td>1,000 addMany</td><td>10.96</td><td>91.27</td><td>0.00</td></tr><tr><td>1,000 get</td><td>18.61</td><td>53.73</td><td>0.00</td></tr><tr><td>1,000 dfs</td><td>164.20</td><td>6.09</td><td>0.04</td></tr><tr><td>1,000 bfs</td><td>58.84</td><td>17.00</td><td>0.01</td></tr><tr><td>1,000 morris</td><td>256.66</td><td>3.90</td><td>7.70e-4</td></tr></table></div>
|
|
424
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
425
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>bst</span></div>
|
|
426
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 add randomly</td><td>31.59</td><td>31.66</td><td>2.74e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>74.56</td><td>13.41</td><td>8.32e-4</td></tr><tr><td>10,000 addMany</td><td>29.16</td><td>34.30</td><td>0.00</td></tr><tr><td>10,000 get</td><td>29.24</td><td>34.21</td><td>0.00</td></tr></table></div>
|
|
427
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
428
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
|
|
429
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>85.85</td><td>11.65</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>211.54</td><td>4.73</td><td>0.00</td></tr><tr><td>100,000 getNode</td><td>37.92</td><td>26.37</td><td>1.65e-4</td></tr></table></div>
|
|
430
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
431
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>comparison</span></div>
|
|
432
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>SRC PQ 10,000 add</td><td>0.57</td><td>1748.73</td><td>4.96e-6</td></tr><tr><td>CJS PQ 10,000 add</td><td>0.57</td><td>1746.69</td><td>4.91e-6</td></tr><tr><td>MJS PQ 10,000 add</td><td>0.57</td><td>1749.68</td><td>4.43e-6</td></tr><tr><td>SRC PQ 10,000 add & pop</td><td>3.47</td><td>288.14</td><td>6.38e-4</td></tr><tr><td>CJS PQ 10,000 add & pop</td><td>3.39</td><td>295.36</td><td>3.90e-5</td></tr><tr><td>MJS PQ 10,000 add & pop</td><td>3.37</td><td>297.17</td><td>3.03e-5</td></tr></table></div>
|
|
433
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
434
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
|
|
435
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000 addVertex</td><td>0.10</td><td>9534.93</td><td>8.72e-7</td></tr><tr><td>1,000 addEdge</td><td>6.30</td><td>158.67</td><td>0.00</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.16e+4</td><td>3.03e-7</td></tr><tr><td>1,000 getEdge</td><td>22.31</td><td>44.82</td><td>0.00</td></tr><tr><td>tarjan</td><td>210.90</td><td>4.74</td><td>0.01</td></tr><tr><td>tarjan all</td><td>214.72</td><td>4.66</td><td>0.01</td></tr><tr><td>topologicalSort</td><td>172.52</td><td>5.80</td><td>0.00</td></tr></table></div>
|
|
436
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
437
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
|
|
438
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 set</td><td>275.88</td><td>3.62</td><td>0.12</td></tr><tr><td>1,000,000 Map set</td><td>211.66</td><td>4.72</td><td>0.01</td></tr><tr><td>1,000,000 Set add</td><td>177.72</td><td>5.63</td><td>0.02</td></tr><tr><td>1,000,000 set & get</td><td>317.60</td><td>3.15</td><td>0.02</td></tr><tr><td>1,000,000 Map set & get</td><td>274.99</td><td>3.64</td><td>0.03</td></tr><tr><td>1,000,000 Set add & has</td><td>172.23</td><td>5.81</td><td>0.02</td></tr><tr><td>1,000,000 ObjKey set & get</td><td>929.40</td><td>1.08</td><td>0.07</td></tr><tr><td>1,000,000 Map ObjKey set & get</td><td>310.02</td><td>3.23</td><td>0.05</td></tr><tr><td>1,000,000 Set ObjKey add & has</td><td>283.28</td><td>3.53</td><td>0.04</td></tr></table></div>
|
|
439
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
440
146
|
<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
|
|
441
147
|
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 add & pop</td><td>5.80</td><td>172.35</td><td>8.78e-5</td></tr><tr><td>10,000 fib add & pop</td><td>357.92</td><td>2.79</td><td>0.00</td></tr></table></div>
|
|
442
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
443
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
|
|
444
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>221.57</td><td>4.51</td><td>0.03</td></tr><tr><td>1,000,000 unshift</td><td>229.02</td><td>4.37</td><td>0.07</td></tr><tr><td>1,000,000 unshift & shift</td><td>169.21</td><td>5.91</td><td>0.02</td></tr><tr><td>1,000,000 insertBefore</td><td>314.48</td><td>3.18</td><td>0.07</td></tr></table></div>
|
|
445
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
446
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</span></div>
|
|
447
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 push & pop</td><td>212.98</td><td>4.70</td><td>0.01</td></tr><tr><td>10,000 insertBefore</td><td>250.68</td><td>3.99</td><td>0.01</td></tr></table></div>
|
|
448
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
449
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>max-priority-queue</span></div>
|
|
450
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 refill & poll</td><td>8.91</td><td>112.29</td><td>2.26e-4</td></tr></table></div>
|
|
451
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
452
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>priority-queue</span></div>
|
|
453
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add & pop</td><td>103.59</td><td>9.65</td><td>0.00</td></tr></table></div>
|
|
454
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
455
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
|
|
456
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>14.55</td><td>68.72</td><td>6.91e-4</td></tr><tr><td>1,000,000 push & pop</td><td>23.40</td><td>42.73</td><td>5.94e-4</td></tr><tr><td>1,000,000 push & shift</td><td>24.41</td><td>40.97</td><td>1.45e-4</td></tr><tr><td>1,000,000 unshift & shift</td><td>22.56</td><td>44.32</td><td>1.30e-4</td></tr></table></div>
|
|
457
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
458
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
|
|
459
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>39.90</td><td>25.07</td><td>0.01</td></tr><tr><td>1,000,000 push & shift</td><td>81.79</td><td>12.23</td><td>0.00</td></tr></table></div>
|
|
460
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
461
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>stack</span></div>
|
|
462
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>37.60</td><td>26.60</td><td>0.00</td></tr><tr><td>1,000,000 push & pop</td><td>47.01</td><td>21.27</td><td>0.00</td></tr></table></div>
|
|
463
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
464
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
|
|
465
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 push</td><td>45.97</td><td>21.76</td><td>0.00</td></tr><tr><td>100,000 getWords</td><td>66.20</td><td>15.11</td><td>0.00</td></tr></table></div>
|
|
466
148
|
</div>
|
|
467
149
|
|
|
468
150
|
[//]: # (No deletion!!! End of Replace Section)
|
|
@@ -478,93 +160,7 @@ yarn add min-heap-typed
|
|
|
478
160
|
</tr>
|
|
479
161
|
</thead>
|
|
480
162
|
<tbody>
|
|
481
|
-
|
|
482
|
-
<td>Binary Tree DFS</td>
|
|
483
|
-
<td>Traverse a binary tree in a depth-first manner, starting from the root node, first visiting the left subtree,
|
|
484
|
-
and then the right subtree, using recursion.
|
|
485
|
-
</td>
|
|
486
|
-
<td>Recursion + Iteration</td>
|
|
487
|
-
</tr>
|
|
488
|
-
<tr>
|
|
489
|
-
<td>Binary Tree BFS</td>
|
|
490
|
-
<td>Traverse a binary tree in a breadth-first manner, starting from the root node, visiting nodes level by level
|
|
491
|
-
from left to right.
|
|
492
|
-
</td>
|
|
493
|
-
<td>Iteration</td>
|
|
494
|
-
</tr>
|
|
495
|
-
<tr>
|
|
496
|
-
<td>Graph DFS</td>
|
|
497
|
-
<td>Traverse a graph in a depth-first manner, starting from a given node, exploring along one path as deeply as
|
|
498
|
-
possible, and backtracking to explore other paths. Used for finding connected components, paths, etc.
|
|
499
|
-
</td>
|
|
500
|
-
<td>Recursion + Iteration</td>
|
|
501
|
-
</tr>
|
|
502
|
-
<tr>
|
|
503
|
-
<td>Binary Tree Morris</td>
|
|
504
|
-
<td>Morris traversal is an in-order traversal algorithm for binary trees with O(1) space complexity. It allows tree
|
|
505
|
-
traversal without additional stack or recursion.
|
|
506
|
-
</td>
|
|
507
|
-
<td>Iteration</td>
|
|
508
|
-
</tr>
|
|
509
|
-
<tr>
|
|
510
|
-
<td>Graph BFS</td>
|
|
511
|
-
<td>Traverse a graph in a breadth-first manner, starting from a given node, first visiting nodes directly connected
|
|
512
|
-
to the starting node, and then expanding level by level. Used for finding shortest paths, etc.
|
|
513
|
-
</td>
|
|
514
|
-
<td>Recursion + Iteration</td>
|
|
515
|
-
</tr>
|
|
516
|
-
<tr>
|
|
517
|
-
<td>Graph Tarjan's Algorithm</td>
|
|
518
|
-
<td>Find strongly connected components in a graph, typically implemented using depth-first search.</td>
|
|
519
|
-
<td>Recursion</td>
|
|
520
|
-
</tr>
|
|
521
|
-
<tr>
|
|
522
|
-
<td>Graph Bellman-Ford Algorithm</td>
|
|
523
|
-
<td>Finding the shortest paths from a single source, can handle negative weight edges</td>
|
|
524
|
-
<td>Iteration</td>
|
|
525
|
-
</tr>
|
|
526
|
-
<tr>
|
|
527
|
-
<td>Graph Dijkstra's Algorithm</td>
|
|
528
|
-
<td>Finding the shortest paths from a single source, cannot handle negative weight edges</td>
|
|
529
|
-
<td>Iteration</td>
|
|
530
|
-
</tr>
|
|
531
|
-
<tr>
|
|
532
|
-
<td>Graph Floyd-Warshall Algorithm</td>
|
|
533
|
-
<td>Finding the shortest paths between all pairs of nodes</td>
|
|
534
|
-
<td>Iteration</td>
|
|
535
|
-
</tr>
|
|
536
|
-
<tr>
|
|
537
|
-
<td>Graph getCycles</td>
|
|
538
|
-
<td>Find all cycles in a graph or detect the presence of cycles.</td>
|
|
539
|
-
<td>Recursion</td>
|
|
540
|
-
</tr>
|
|
541
|
-
<tr>
|
|
542
|
-
<td>Graph getCutVertexes</td>
|
|
543
|
-
<td>Find cut vertices in a graph, which are nodes that, when removed, increase the number of connected components in
|
|
544
|
-
the graph.
|
|
545
|
-
</td>
|
|
546
|
-
<td>Recursion</td>
|
|
547
|
-
</tr>
|
|
548
|
-
<tr>
|
|
549
|
-
<td>Graph getSCCs</td>
|
|
550
|
-
<td>Find strongly connected components in a graph, which are subgraphs where any two nodes can reach each other.
|
|
551
|
-
</td>
|
|
552
|
-
<td>Recursion</td>
|
|
553
|
-
</tr>
|
|
554
|
-
<tr>
|
|
555
|
-
<td>Graph getBridges</td>
|
|
556
|
-
<td>Find bridges in a graph, which are edges that, when removed, increase the number of connected components in the
|
|
557
|
-
graph.
|
|
558
|
-
</td>
|
|
559
|
-
<td>Recursion</td>
|
|
560
|
-
</tr>
|
|
561
|
-
<tr>
|
|
562
|
-
<td>Graph topologicalSort</td>
|
|
563
|
-
<td>Perform topological sorting on a directed acyclic graph (DAG) to find a linear order of nodes such that all
|
|
564
|
-
directed edges go from earlier nodes to later nodes.
|
|
565
|
-
</td>
|
|
566
|
-
<td>Recursion</td>
|
|
567
|
-
</tr>
|
|
163
|
+
|
|
568
164
|
</tbody>
|
|
569
165
|
</table>
|
|
570
166
|
|
|
@@ -266,9 +266,9 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
266
266
|
* @returns a boolean value.
|
|
267
267
|
*/
|
|
268
268
|
isRealNode(node) {
|
|
269
|
-
if (
|
|
269
|
+
if (node === this.NIL || node === null || node === undefined)
|
|
270
270
|
return false;
|
|
271
|
-
return
|
|
271
|
+
return this.isNode(node);
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
274
274
|
* The function checks if a given node is a BinaryTreeNode instance and has a key value of NaN.
|
|
@@ -608,7 +608,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
608
608
|
if (!current)
|
|
609
609
|
return undefined;
|
|
610
610
|
if (this._variant === 'STANDARD') {
|
|
611
|
-
// For
|
|
611
|
+
// For 'STANDARD', find the rightmost node
|
|
612
612
|
while (current.right !== undefined) {
|
|
613
613
|
current = current.right;
|
|
614
614
|
}
|
|
@@ -4,9 +4,9 @@ export * from './stack';
|
|
|
4
4
|
export * from './queue';
|
|
5
5
|
export * from './graph';
|
|
6
6
|
export * from './binary-tree';
|
|
7
|
-
export * from './tree';
|
|
8
7
|
export * from './heap';
|
|
9
8
|
export * from './priority-queue';
|
|
10
9
|
export * from './matrix';
|
|
11
10
|
export * from './trie';
|
|
12
11
|
export * from './base';
|
|
12
|
+
export * from './tree';
|
|
@@ -20,9 +20,9 @@ __exportStar(require("./stack"), exports);
|
|
|
20
20
|
__exportStar(require("./queue"), exports);
|
|
21
21
|
__exportStar(require("./graph"), exports);
|
|
22
22
|
__exportStar(require("./binary-tree"), exports);
|
|
23
|
-
__exportStar(require("./tree"), exports);
|
|
24
23
|
__exportStar(require("./heap"), exports);
|
|
25
24
|
__exportStar(require("./priority-queue"), exports);
|
|
26
25
|
__exportStar(require("./matrix"), exports);
|
|
27
26
|
__exportStar(require("./trie"), exports);
|
|
28
27
|
__exportStar(require("./base"), exports);
|
|
28
|
+
__exportStar(require("./tree"), exports);
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toBinaryString(num: number, digit?: number): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBinaryString = void 0;
|
|
4
|
+
function toBinaryString(num, digit = 32) {
|
|
5
|
+
// Convert number to binary string
|
|
6
|
+
let binaryString = (num >>> 0).toString(2); // Use the unsigned right shift operator to ensure you get a binary representation of a 32-bit unsigned integer
|
|
7
|
+
// Use pad Start to ensure the string length is 32 bits
|
|
8
|
+
binaryString = binaryString.padStart(digit, '0');
|
|
9
|
+
return binaryString;
|
|
10
|
+
}
|
|
11
|
+
exports.toBinaryString = toBinaryString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "min-heap-typed",
|
|
3
|
-
"version": "1.51.
|
|
3
|
+
"version": "1.51.4",
|
|
4
4
|
"description": "Min Heap. Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -132,6 +132,6 @@
|
|
|
132
132
|
"typescript": "^4.9.5"
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
|
-
"data-structure-typed": "^1.51.
|
|
135
|
+
"data-structure-typed": "^1.51.4"
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -316,8 +316,8 @@ export class BinaryTree<
|
|
|
316
316
|
* @returns a boolean value.
|
|
317
317
|
*/
|
|
318
318
|
isRealNode(node: KeyOrNodeOrEntry<K, V, NODE>): node is NODE {
|
|
319
|
-
if (
|
|
320
|
-
return
|
|
319
|
+
if (node === this.NIL || node === null || node === undefined) return false;
|
|
320
|
+
return this.isNode(node);
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
/**
|
|
@@ -695,7 +695,7 @@ export class BST<
|
|
|
695
695
|
if (!current) return undefined;
|
|
696
696
|
|
|
697
697
|
if (this._variant === 'STANDARD') {
|
|
698
|
-
// For
|
|
698
|
+
// For 'STANDARD', find the rightmost node
|
|
699
699
|
while (current.right !== undefined) {
|
|
700
700
|
current = current.right;
|
|
701
701
|
}
|
|
@@ -4,9 +4,9 @@ export * from './stack';
|
|
|
4
4
|
export * from './queue';
|
|
5
5
|
export * from './graph';
|
|
6
6
|
export * from './binary-tree';
|
|
7
|
-
export * from './tree';
|
|
8
7
|
export * from './heap';
|
|
9
8
|
export * from './priority-queue';
|
|
10
9
|
export * from './matrix';
|
|
11
10
|
export * from './trie';
|
|
12
11
|
export * from './base';
|
|
12
|
+
export * from './tree';
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function toBinaryString(num: number, digit = 32) {
|
|
2
|
+
// Convert number to binary string
|
|
3
|
+
let binaryString = (num >>> 0).toString(2); // Use the unsigned right shift operator to ensure you get a binary representation of a 32-bit unsigned integer
|
|
4
|
+
|
|
5
|
+
// Use pad Start to ensure the string length is 32 bits
|
|
6
|
+
binaryString = binaryString.padStart(digit, '0');
|
|
7
|
+
|
|
8
|
+
return binaryString;
|
|
9
|
+
}
|