red-black-tree-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 +7 -388
- 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
|
|
|
@@ -246,132 +246,14 @@ lastBFSNodes[0].id // 12
|
|
|
246
246
|
</tr>
|
|
247
247
|
</thead>
|
|
248
248
|
<tbody>
|
|
249
|
-
|
|
250
|
-
<td>Binary Tree</td>
|
|
251
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
252
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
253
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary Tree</span></a></td>
|
|
254
|
-
</tr>
|
|
255
|
-
<tr>
|
|
256
|
-
<td>Binary Search Tree (BST)</td>
|
|
257
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
258
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
259
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></td>
|
|
260
|
-
</tr>
|
|
261
|
-
<tr>
|
|
262
|
-
<td>AVL Tree</td>
|
|
263
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
264
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
265
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></td>
|
|
266
|
-
</tr>
|
|
249
|
+
|
|
267
250
|
<tr>
|
|
268
251
|
<td>Red Black Tree</td>
|
|
269
252
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
270
253
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
271
254
|
<td><a href="https://data-structure-typed-docs.vercel.app/classes/RedBlackTree.html"><span>RedBlackTree</span></a></td>
|
|
272
255
|
</tr>
|
|
273
|
-
|
|
274
|
-
<td>Tree Multiset</td>
|
|
275
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
276
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
277
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultimap.html"><span>TreeMultimap</span></a></td>
|
|
278
|
-
</tr>
|
|
279
|
-
<tr>
|
|
280
|
-
<td>Segment Tree</td>
|
|
281
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
282
|
-
<td></td>
|
|
283
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>SegmentTree</span></a></td>
|
|
284
|
-
</tr>
|
|
285
|
-
<tr>
|
|
286
|
-
<td>Binary Indexed Tree</td>
|
|
287
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
288
|
-
<td></td>
|
|
289
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>BinaryIndexedTree</span></a></td>
|
|
290
|
-
</tr>
|
|
291
|
-
<tr>
|
|
292
|
-
<td>Heap</td>
|
|
293
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
294
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
295
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html"><span>Heap</span></a></td>
|
|
296
|
-
</tr>
|
|
297
|
-
<tr>
|
|
298
|
-
<td>Priority Queue</td>
|
|
299
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
300
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
301
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>PriorityQueue</span></a></td>
|
|
302
|
-
</tr>
|
|
303
|
-
<tr>
|
|
304
|
-
<td>Max Priority Queue</td>
|
|
305
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
306
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
307
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html"><span>MaxPriorityQueue</span></a></td>
|
|
308
|
-
</tr>
|
|
309
|
-
<tr>
|
|
310
|
-
<td>Min Priority Queue</td>
|
|
311
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
312
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
313
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html"><span>MinPriorityQueue</span></a></td>
|
|
314
|
-
</tr>
|
|
315
|
-
<tr>
|
|
316
|
-
<td>Trie</td>
|
|
317
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
318
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
319
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></td>
|
|
320
|
-
</tr>
|
|
321
|
-
<tr>
|
|
322
|
-
<td>Graph</td>
|
|
323
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
324
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
325
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>AbstractGraph</span></a></td>
|
|
326
|
-
</tr>
|
|
327
|
-
<tr>
|
|
328
|
-
<td>Directed Graph</td>
|
|
329
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
330
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
331
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html"><span>DirectedGraph</span></a></td>
|
|
332
|
-
</tr>
|
|
333
|
-
<tr>
|
|
334
|
-
<td>Undirected Graph</td>
|
|
335
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
336
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
337
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>UndirectedGraph</span></a></td>
|
|
338
|
-
</tr>
|
|
339
|
-
<tr>
|
|
340
|
-
<td>Queue</td>
|
|
341
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
342
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
343
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></td>
|
|
344
|
-
</tr>
|
|
345
|
-
<tr>
|
|
346
|
-
<td>Deque</td>
|
|
347
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
348
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
349
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html"><span>Deque</span></a></td>
|
|
350
|
-
</tr>
|
|
351
|
-
<tr>
|
|
352
|
-
<td>Linked List</td>
|
|
353
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
354
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
355
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
356
|
-
</tr>
|
|
357
|
-
<tr>
|
|
358
|
-
<td>Singly Linked List</td>
|
|
359
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
360
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
361
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
362
|
-
</tr>
|
|
363
|
-
<tr>
|
|
364
|
-
<td>Doubly Linked List</td>
|
|
365
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
366
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
367
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html"><span>DoublyLinkedList</span></a></td>
|
|
368
|
-
</tr>
|
|
369
|
-
<tr>
|
|
370
|
-
<td>Stack</td>
|
|
371
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
372
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
373
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></td>
|
|
374
|
-
</tr>
|
|
256
|
+
|
|
375
257
|
</tbody>
|
|
376
258
|
</table>
|
|
377
259
|
|
|
@@ -387,168 +269,14 @@ lastBFSNodes[0].id // 12
|
|
|
387
269
|
</tr>
|
|
388
270
|
</thead>
|
|
389
271
|
<tbody>
|
|
390
|
-
|
|
391
|
-
<td>Heap<E></td>
|
|
392
|
-
<td>priority_queue<T></td>
|
|
393
|
-
<td>PriorityQueue<E></td>
|
|
394
|
-
<td>heapq</td>
|
|
395
|
-
</tr>
|
|
396
|
-
<tr>
|
|
397
|
-
<td>Deque<E></td>
|
|
398
|
-
<td>deque<T></td>
|
|
399
|
-
<td>ArrayDeque<E></td>
|
|
400
|
-
<td>deque</td>
|
|
401
|
-
</tr>
|
|
402
|
-
<tr>
|
|
403
|
-
<td>Queue<E></td>
|
|
404
|
-
<td>queue<T></td>
|
|
405
|
-
<td>Queue<E></td>
|
|
406
|
-
<td>-</td>
|
|
407
|
-
</tr>
|
|
408
|
-
<tr>
|
|
409
|
-
<td>HashMap<K, V></td>
|
|
410
|
-
<td>unordered_map<K, V></td>
|
|
411
|
-
<td>HashMap<K, V></td>
|
|
412
|
-
<td>defaultdict</td>
|
|
413
|
-
</tr>
|
|
414
|
-
<tr>
|
|
415
|
-
<td>DoublyLinkedList<E></td>
|
|
416
|
-
<td>list<T></td>
|
|
417
|
-
<td>LinkedList<E></td>
|
|
418
|
-
<td>-</td>
|
|
419
|
-
</tr>
|
|
420
|
-
<tr>
|
|
421
|
-
<td>SinglyLinkedList<E></td>
|
|
422
|
-
<td>-</td>
|
|
423
|
-
<td>-</td>
|
|
424
|
-
<td>-</td>
|
|
425
|
-
</tr>
|
|
426
|
-
<tr>
|
|
427
|
-
<td>BinaryTree<K, V></td>
|
|
428
|
-
<td>-</td>
|
|
429
|
-
<td>-</td>
|
|
430
|
-
<td>-</td>
|
|
431
|
-
</tr>
|
|
432
|
-
<tr>
|
|
433
|
-
<td>BST<K, V></td>
|
|
434
|
-
<td>-</td>
|
|
435
|
-
<td>-</td>
|
|
436
|
-
<td>-</td>
|
|
437
|
-
</tr>
|
|
438
|
-
<tr>
|
|
439
|
-
<td>RedBlackTree<E></td>
|
|
440
|
-
<td>set<T></td>
|
|
441
|
-
<td>TreeSet<E></td>
|
|
442
|
-
<td>-</td>
|
|
443
|
-
</tr>
|
|
272
|
+
|
|
444
273
|
<tr>
|
|
445
274
|
<td>RedBlackTree<K, V></td>
|
|
446
275
|
<td>map<K, V></td>
|
|
447
276
|
<td>TreeMap<K, V></td>
|
|
448
277
|
<td>-</td>
|
|
449
278
|
</tr>
|
|
450
|
-
|
|
451
|
-
<td>TreeMultimap<K, V></td>
|
|
452
|
-
<td>multimap<K, V></td>
|
|
453
|
-
<td>-</td>
|
|
454
|
-
<td>-</td>
|
|
455
|
-
</tr>
|
|
456
|
-
<tr>
|
|
457
|
-
<td>-</td>
|
|
458
|
-
<td>multiset<T></td>
|
|
459
|
-
<td>-</td>
|
|
460
|
-
<td>-</td>
|
|
461
|
-
</tr>
|
|
462
|
-
<tr>
|
|
463
|
-
<td>Trie</td>
|
|
464
|
-
<td>-</td>
|
|
465
|
-
<td>-</td>
|
|
466
|
-
<td>-</td>
|
|
467
|
-
</tr>
|
|
468
|
-
<tr>
|
|
469
|
-
<td>DirectedGraph<V, E></td>
|
|
470
|
-
<td>-</td>
|
|
471
|
-
<td>-</td>
|
|
472
|
-
<td>-</td>
|
|
473
|
-
</tr>
|
|
474
|
-
<tr>
|
|
475
|
-
<td>UndirectedGraph<V, E></td>
|
|
476
|
-
<td>-</td>
|
|
477
|
-
<td>-</td>
|
|
478
|
-
<td>-</td>
|
|
479
|
-
</tr>
|
|
480
|
-
<tr>
|
|
481
|
-
<td>PriorityQueue<E></td>
|
|
482
|
-
<td>priority_queue<T></td>
|
|
483
|
-
<td>PriorityQueue<E></td>
|
|
484
|
-
<td>-</td>
|
|
485
|
-
</tr>
|
|
486
|
-
<tr>
|
|
487
|
-
<td>Array<E></td>
|
|
488
|
-
<td>vector<T></td>
|
|
489
|
-
<td>ArrayList<E></td>
|
|
490
|
-
<td>list</td>
|
|
491
|
-
</tr>
|
|
492
|
-
<tr>
|
|
493
|
-
<td>Stack<E></td>
|
|
494
|
-
<td>stack<T></td>
|
|
495
|
-
<td>Stack<E></td>
|
|
496
|
-
<td>-</td>
|
|
497
|
-
</tr>
|
|
498
|
-
<tr>
|
|
499
|
-
<td>Set<E></td>
|
|
500
|
-
<td>-</td>
|
|
501
|
-
<td>HashSet<E></td>
|
|
502
|
-
<td>set</td>
|
|
503
|
-
</tr>
|
|
504
|
-
<tr>
|
|
505
|
-
<td>Map<K, V></td>
|
|
506
|
-
<td>-</td>
|
|
507
|
-
<td>HashMap<K, V></td>
|
|
508
|
-
<td>dict</td>
|
|
509
|
-
</tr>
|
|
510
|
-
<tr>
|
|
511
|
-
<td>-</td>
|
|
512
|
-
<td>unordered_set<T></td>
|
|
513
|
-
<td>HashSet<E></td>
|
|
514
|
-
<td>-</td>
|
|
515
|
-
</tr>
|
|
516
|
-
<tr>
|
|
517
|
-
<td>Map<K, V></td>
|
|
518
|
-
<td>-</td>
|
|
519
|
-
<td>-</td>
|
|
520
|
-
<td>OrderedDict</td>
|
|
521
|
-
</tr>
|
|
522
|
-
<tr>
|
|
523
|
-
<td>-</td>
|
|
524
|
-
<td>unordered_multiset</td>
|
|
525
|
-
<td>-</td>
|
|
526
|
-
<td>Counter</td>
|
|
527
|
-
</tr>
|
|
528
|
-
<tr>
|
|
529
|
-
<td>-</td>
|
|
530
|
-
<td>-</td>
|
|
531
|
-
<td>LinkedHashSet<E></td>
|
|
532
|
-
<td>-</td>
|
|
533
|
-
</tr>
|
|
534
|
-
<tr>
|
|
535
|
-
<td>HashMap<K, V></td>
|
|
536
|
-
<td>-</td>
|
|
537
|
-
<td>LinkedHashMap<K, V></td>
|
|
538
|
-
<td>-</td>
|
|
539
|
-
</tr>
|
|
540
|
-
<tr>
|
|
541
|
-
<td>-</td>
|
|
542
|
-
<td>unordered_multimap<K, V></td>
|
|
543
|
-
<td>-</td>
|
|
544
|
-
<td>-</td>
|
|
545
|
-
</tr>
|
|
546
|
-
<tr>
|
|
547
|
-
<td>-</td>
|
|
548
|
-
<td>bitset<N></td>
|
|
549
|
-
<td>-</td>
|
|
550
|
-
<td>-</td>
|
|
551
|
-
</tr>
|
|
279
|
+
|
|
552
280
|
</tbody>
|
|
553
281
|
</table>
|
|
554
282
|
|
|
@@ -556,53 +284,8 @@ lastBFSNodes[0].id // 12
|
|
|
556
284
|
|
|
557
285
|
[//]: # (No deletion!!! Start of Replace Section)
|
|
558
286
|
<div class="json-to-html-collapse clearfix 0">
|
|
559
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
|
|
560
|
-
<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>
|
|
561
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
562
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>binary-tree</span></div>
|
|
563
|
-
<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>
|
|
564
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
565
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>bst</span></div>
|
|
566
|
-
<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>
|
|
567
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
568
287
|
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
|
|
569
288
|
<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>
|
|
570
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
571
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>comparison</span></div>
|
|
572
|
-
<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>
|
|
573
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
574
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
|
|
575
|
-
<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>
|
|
576
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
577
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
|
|
578
|
-
<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>
|
|
579
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
580
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
|
|
581
|
-
<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>
|
|
582
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
583
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
|
|
584
|
-
<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>
|
|
585
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
586
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</span></div>
|
|
587
|
-
<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>
|
|
588
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
589
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>max-priority-queue</span></div>
|
|
590
|
-
<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>
|
|
591
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
592
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>priority-queue</span></div>
|
|
593
|
-
<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>
|
|
594
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
595
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
|
|
596
|
-
<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>
|
|
597
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
598
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
|
|
599
|
-
<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>
|
|
600
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
601
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>stack</span></div>
|
|
602
|
-
<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>
|
|
603
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
604
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
|
|
605
|
-
<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>
|
|
606
289
|
</div>
|
|
607
290
|
|
|
608
291
|
[//]: # (No deletion!!! End of Replace Section)
|
|
@@ -632,13 +315,7 @@ lastBFSNodes[0].id // 12
|
|
|
632
315
|
</td>
|
|
633
316
|
<td>Iteration</td>
|
|
634
317
|
</tr>
|
|
635
|
-
|
|
636
|
-
<td>Graph DFS</td>
|
|
637
|
-
<td>Traverse a graph in a depth-first manner, starting from a given node, exploring along one path as deeply as
|
|
638
|
-
possible, and backtracking to explore other paths. Used for finding connected components, paths, etc.
|
|
639
|
-
</td>
|
|
640
|
-
<td>Recursion + Iteration</td>
|
|
641
|
-
</tr>
|
|
318
|
+
|
|
642
319
|
<tr>
|
|
643
320
|
<td>Binary Tree Morris</td>
|
|
644
321
|
<td>Morris traversal is an in-order traversal algorithm for binary trees with O(1) space complexity. It allows tree
|
|
@@ -646,65 +323,7 @@ lastBFSNodes[0].id // 12
|
|
|
646
323
|
</td>
|
|
647
324
|
<td>Iteration</td>
|
|
648
325
|
</tr>
|
|
649
|
-
|
|
650
|
-
<td>Graph BFS</td>
|
|
651
|
-
<td>Traverse a graph in a breadth-first manner, starting from a given node, first visiting nodes directly connected
|
|
652
|
-
to the starting node, and then expanding level by level. Used for finding shortest paths, etc.
|
|
653
|
-
</td>
|
|
654
|
-
<td>Recursion + Iteration</td>
|
|
655
|
-
</tr>
|
|
656
|
-
<tr>
|
|
657
|
-
<td>Graph Tarjan's Algorithm</td>
|
|
658
|
-
<td>Find strongly connected components in a graph, typically implemented using depth-first search.</td>
|
|
659
|
-
<td>Recursion</td>
|
|
660
|
-
</tr>
|
|
661
|
-
<tr>
|
|
662
|
-
<td>Graph Bellman-Ford Algorithm</td>
|
|
663
|
-
<td>Finding the shortest paths from a single source, can handle negative weight edges</td>
|
|
664
|
-
<td>Iteration</td>
|
|
665
|
-
</tr>
|
|
666
|
-
<tr>
|
|
667
|
-
<td>Graph Dijkstra's Algorithm</td>
|
|
668
|
-
<td>Finding the shortest paths from a single source, cannot handle negative weight edges</td>
|
|
669
|
-
<td>Iteration</td>
|
|
670
|
-
</tr>
|
|
671
|
-
<tr>
|
|
672
|
-
<td>Graph Floyd-Warshall Algorithm</td>
|
|
673
|
-
<td>Finding the shortest paths between all pairs of nodes</td>
|
|
674
|
-
<td>Iteration</td>
|
|
675
|
-
</tr>
|
|
676
|
-
<tr>
|
|
677
|
-
<td>Graph getCycles</td>
|
|
678
|
-
<td>Find all cycles in a graph or detect the presence of cycles.</td>
|
|
679
|
-
<td>Recursion</td>
|
|
680
|
-
</tr>
|
|
681
|
-
<tr>
|
|
682
|
-
<td>Graph getCutVertexes</td>
|
|
683
|
-
<td>Find cut vertices in a graph, which are nodes that, when removed, increase the number of connected components in
|
|
684
|
-
the graph.
|
|
685
|
-
</td>
|
|
686
|
-
<td>Recursion</td>
|
|
687
|
-
</tr>
|
|
688
|
-
<tr>
|
|
689
|
-
<td>Graph getSCCs</td>
|
|
690
|
-
<td>Find strongly connected components in a graph, which are subgraphs where any two nodes can reach each other.
|
|
691
|
-
</td>
|
|
692
|
-
<td>Recursion</td>
|
|
693
|
-
</tr>
|
|
694
|
-
<tr>
|
|
695
|
-
<td>Graph getBridges</td>
|
|
696
|
-
<td>Find bridges in a graph, which are edges that, when removed, increase the number of connected components in the
|
|
697
|
-
graph.
|
|
698
|
-
</td>
|
|
699
|
-
<td>Recursion</td>
|
|
700
|
-
</tr>
|
|
701
|
-
<tr>
|
|
702
|
-
<td>Graph topologicalSort</td>
|
|
703
|
-
<td>Perform topological sorting on a directed acyclic graph (DAG) to find a linear order of nodes such that all
|
|
704
|
-
directed edges go from earlier nodes to later nodes.
|
|
705
|
-
</td>
|
|
706
|
-
<td>Recursion</td>
|
|
707
|
-
</tr>
|
|
326
|
+
|
|
708
327
|
</tbody>
|
|
709
328
|
</table>
|
|
710
329
|
|
|
@@ -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": "red-black-tree-typed",
|
|
3
|
-
"version": "1.51.
|
|
3
|
+
"version": "1.51.4",
|
|
4
4
|
"description": "RedBlackTree. Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -142,6 +142,6 @@
|
|
|
142
142
|
"typescript": "^4.9.5"
|
|
143
143
|
},
|
|
144
144
|
"dependencies": {
|
|
145
|
-
"data-structure-typed": "^1.51.
|
|
145
|
+
"data-structure-typed": "^1.51.4"
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -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
|
+
}
|