bst-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 -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
|
|
|
@@ -367,132 +367,15 @@ bfsNodes[2].id; // 16
|
|
|
367
367
|
</tr>
|
|
368
368
|
</thead>
|
|
369
369
|
<tbody>
|
|
370
|
-
|
|
371
|
-
<td>Binary Tree</td>
|
|
372
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
373
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
374
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary Tree</span></a></td>
|
|
375
|
-
</tr>
|
|
370
|
+
|
|
376
371
|
<tr>
|
|
377
372
|
<td>Binary Search Tree (BST)</td>
|
|
378
373
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
379
374
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
380
375
|
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></td>
|
|
381
376
|
</tr>
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
385
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
386
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></td>
|
|
387
|
-
</tr>
|
|
388
|
-
<tr>
|
|
389
|
-
<td>Red Black Tree</td>
|
|
390
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
391
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
392
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/RedBlackTree.html"><span>RedBlackTree</span></a></td>
|
|
393
|
-
</tr>
|
|
394
|
-
<tr>
|
|
395
|
-
<td>Tree Multiset</td>
|
|
396
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
397
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
398
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultimap.html"><span>TreeMultimap</span></a></td>
|
|
399
|
-
</tr>
|
|
400
|
-
<tr>
|
|
401
|
-
<td>Segment Tree</td>
|
|
402
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
403
|
-
<td></td>
|
|
404
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>SegmentTree</span></a></td>
|
|
405
|
-
</tr>
|
|
406
|
-
<tr>
|
|
407
|
-
<td>Binary Indexed Tree</td>
|
|
408
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
409
|
-
<td></td>
|
|
410
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>BinaryIndexedTree</span></a></td>
|
|
411
|
-
</tr>
|
|
412
|
-
<tr>
|
|
413
|
-
<td>Heap</td>
|
|
414
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
415
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
416
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html"><span>Heap</span></a></td>
|
|
417
|
-
</tr>
|
|
418
|
-
<tr>
|
|
419
|
-
<td>Priority Queue</td>
|
|
420
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
421
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
422
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>PriorityQueue</span></a></td>
|
|
423
|
-
</tr>
|
|
424
|
-
<tr>
|
|
425
|
-
<td>Max Priority Queue</td>
|
|
426
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
427
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
428
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html"><span>MaxPriorityQueue</span></a></td>
|
|
429
|
-
</tr>
|
|
430
|
-
<tr>
|
|
431
|
-
<td>Min Priority Queue</td>
|
|
432
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
433
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
434
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html"><span>MinPriorityQueue</span></a></td>
|
|
435
|
-
</tr>
|
|
436
|
-
<tr>
|
|
437
|
-
<td>Trie</td>
|
|
438
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
439
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
440
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></td>
|
|
441
|
-
</tr>
|
|
442
|
-
<tr>
|
|
443
|
-
<td>Graph</td>
|
|
444
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
445
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
446
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>AbstractGraph</span></a></td>
|
|
447
|
-
</tr>
|
|
448
|
-
<tr>
|
|
449
|
-
<td>Directed Graph</td>
|
|
450
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
451
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
452
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html"><span>DirectedGraph</span></a></td>
|
|
453
|
-
</tr>
|
|
454
|
-
<tr>
|
|
455
|
-
<td>Undirected Graph</td>
|
|
456
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
457
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
458
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>UndirectedGraph</span></a></td>
|
|
459
|
-
</tr>
|
|
460
|
-
<tr>
|
|
461
|
-
<td>Queue</td>
|
|
462
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
463
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
464
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></td>
|
|
465
|
-
</tr>
|
|
466
|
-
<tr>
|
|
467
|
-
<td>Deque</td>
|
|
468
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
469
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
470
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html"><span>Deque</span></a></td>
|
|
471
|
-
</tr>
|
|
472
|
-
<tr>
|
|
473
|
-
<td>Linked List</td>
|
|
474
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
475
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
476
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
477
|
-
</tr>
|
|
478
|
-
<tr>
|
|
479
|
-
<td>Singly Linked List</td>
|
|
480
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
481
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
482
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
483
|
-
</tr>
|
|
484
|
-
<tr>
|
|
485
|
-
<td>Doubly Linked List</td>
|
|
486
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
487
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
488
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html"><span>DoublyLinkedList</span></a></td>
|
|
489
|
-
</tr>
|
|
490
|
-
<tr>
|
|
491
|
-
<td>Stack</td>
|
|
492
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
493
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
494
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></td>
|
|
495
|
-
</tr>
|
|
377
|
+
|
|
378
|
+
|
|
496
379
|
</tbody>
|
|
497
380
|
</table>
|
|
498
381
|
|
|
@@ -508,168 +391,13 @@ bfsNodes[2].id; // 16
|
|
|
508
391
|
</tr>
|
|
509
392
|
</thead>
|
|
510
393
|
<tbody>
|
|
511
|
-
<tr>
|
|
512
|
-
<td>Heap<E></td>
|
|
513
|
-
<td>priority_queue<T></td>
|
|
514
|
-
<td>PriorityQueue<E></td>
|
|
515
|
-
<td>heapq</td>
|
|
516
|
-
</tr>
|
|
517
|
-
<tr>
|
|
518
|
-
<td>Deque<E></td>
|
|
519
|
-
<td>deque<T></td>
|
|
520
|
-
<td>ArrayDeque<E></td>
|
|
521
|
-
<td>deque</td>
|
|
522
|
-
</tr>
|
|
523
|
-
<tr>
|
|
524
|
-
<td>Queue<E></td>
|
|
525
|
-
<td>queue<T></td>
|
|
526
|
-
<td>Queue<E></td>
|
|
527
|
-
<td>-</td>
|
|
528
|
-
</tr>
|
|
529
|
-
<tr>
|
|
530
|
-
<td>HashMap<K, V></td>
|
|
531
|
-
<td>unordered_map<K, V></td>
|
|
532
|
-
<td>HashMap<K, V></td>
|
|
533
|
-
<td>defaultdict</td>
|
|
534
|
-
</tr>
|
|
535
|
-
<tr>
|
|
536
|
-
<td>DoublyLinkedList<E></td>
|
|
537
|
-
<td>list<T></td>
|
|
538
|
-
<td>LinkedList<E></td>
|
|
539
|
-
<td>-</td>
|
|
540
|
-
</tr>
|
|
541
|
-
<tr>
|
|
542
|
-
<td>SinglyLinkedList<E></td>
|
|
543
|
-
<td>-</td>
|
|
544
|
-
<td>-</td>
|
|
545
|
-
<td>-</td>
|
|
546
|
-
</tr>
|
|
547
|
-
<tr>
|
|
548
|
-
<td>BinaryTree<K, V></td>
|
|
549
|
-
<td>-</td>
|
|
550
|
-
<td>-</td>
|
|
551
|
-
<td>-</td>
|
|
552
|
-
</tr>
|
|
553
394
|
<tr>
|
|
554
395
|
<td>BST<K, V></td>
|
|
555
396
|
<td>-</td>
|
|
556
397
|
<td>-</td>
|
|
557
398
|
<td>-</td>
|
|
558
399
|
</tr>
|
|
559
|
-
|
|
560
|
-
<td>RedBlackTree<E></td>
|
|
561
|
-
<td>set<T></td>
|
|
562
|
-
<td>TreeSet<E></td>
|
|
563
|
-
<td>-</td>
|
|
564
|
-
</tr>
|
|
565
|
-
<tr>
|
|
566
|
-
<td>RedBlackTree<K, V></td>
|
|
567
|
-
<td>map<K, V></td>
|
|
568
|
-
<td>TreeMap<K, V></td>
|
|
569
|
-
<td>-</td>
|
|
570
|
-
</tr>
|
|
571
|
-
<tr>
|
|
572
|
-
<td>TreeMultimap<K, V></td>
|
|
573
|
-
<td>multimap<K, V></td>
|
|
574
|
-
<td>-</td>
|
|
575
|
-
<td>-</td>
|
|
576
|
-
</tr>
|
|
577
|
-
<tr>
|
|
578
|
-
<td>-</td>
|
|
579
|
-
<td>multiset<T></td>
|
|
580
|
-
<td>-</td>
|
|
581
|
-
<td>-</td>
|
|
582
|
-
</tr>
|
|
583
|
-
<tr>
|
|
584
|
-
<td>Trie</td>
|
|
585
|
-
<td>-</td>
|
|
586
|
-
<td>-</td>
|
|
587
|
-
<td>-</td>
|
|
588
|
-
</tr>
|
|
589
|
-
<tr>
|
|
590
|
-
<td>DirectedGraph<V, E></td>
|
|
591
|
-
<td>-</td>
|
|
592
|
-
<td>-</td>
|
|
593
|
-
<td>-</td>
|
|
594
|
-
</tr>
|
|
595
|
-
<tr>
|
|
596
|
-
<td>UndirectedGraph<V, E></td>
|
|
597
|
-
<td>-</td>
|
|
598
|
-
<td>-</td>
|
|
599
|
-
<td>-</td>
|
|
600
|
-
</tr>
|
|
601
|
-
<tr>
|
|
602
|
-
<td>PriorityQueue<E></td>
|
|
603
|
-
<td>priority_queue<T></td>
|
|
604
|
-
<td>PriorityQueue<E></td>
|
|
605
|
-
<td>-</td>
|
|
606
|
-
</tr>
|
|
607
|
-
<tr>
|
|
608
|
-
<td>Array<E></td>
|
|
609
|
-
<td>vector<T></td>
|
|
610
|
-
<td>ArrayList<E></td>
|
|
611
|
-
<td>list</td>
|
|
612
|
-
</tr>
|
|
613
|
-
<tr>
|
|
614
|
-
<td>Stack<E></td>
|
|
615
|
-
<td>stack<T></td>
|
|
616
|
-
<td>Stack<E></td>
|
|
617
|
-
<td>-</td>
|
|
618
|
-
</tr>
|
|
619
|
-
<tr>
|
|
620
|
-
<td>Set<E></td>
|
|
621
|
-
<td>-</td>
|
|
622
|
-
<td>HashSet<E></td>
|
|
623
|
-
<td>set</td>
|
|
624
|
-
</tr>
|
|
625
|
-
<tr>
|
|
626
|
-
<td>Map<K, V></td>
|
|
627
|
-
<td>-</td>
|
|
628
|
-
<td>HashMap<K, V></td>
|
|
629
|
-
<td>dict</td>
|
|
630
|
-
</tr>
|
|
631
|
-
<tr>
|
|
632
|
-
<td>-</td>
|
|
633
|
-
<td>unordered_set<T></td>
|
|
634
|
-
<td>HashSet<E></td>
|
|
635
|
-
<td>-</td>
|
|
636
|
-
</tr>
|
|
637
|
-
<tr>
|
|
638
|
-
<td>Map<K, V></td>
|
|
639
|
-
<td>-</td>
|
|
640
|
-
<td>-</td>
|
|
641
|
-
<td>OrderedDict</td>
|
|
642
|
-
</tr>
|
|
643
|
-
<tr>
|
|
644
|
-
<td>-</td>
|
|
645
|
-
<td>unordered_multiset</td>
|
|
646
|
-
<td>-</td>
|
|
647
|
-
<td>Counter</td>
|
|
648
|
-
</tr>
|
|
649
|
-
<tr>
|
|
650
|
-
<td>-</td>
|
|
651
|
-
<td>-</td>
|
|
652
|
-
<td>LinkedHashSet<E></td>
|
|
653
|
-
<td>-</td>
|
|
654
|
-
</tr>
|
|
655
|
-
<tr>
|
|
656
|
-
<td>HashMap<K, V></td>
|
|
657
|
-
<td>-</td>
|
|
658
|
-
<td>LinkedHashMap<K, V></td>
|
|
659
|
-
<td>-</td>
|
|
660
|
-
</tr>
|
|
661
|
-
<tr>
|
|
662
|
-
<td>-</td>
|
|
663
|
-
<td>unordered_multimap<K, V></td>
|
|
664
|
-
<td>-</td>
|
|
665
|
-
<td>-</td>
|
|
666
|
-
</tr>
|
|
667
|
-
<tr>
|
|
668
|
-
<td>-</td>
|
|
669
|
-
<td>bitset<N></td>
|
|
670
|
-
<td>-</td>
|
|
671
|
-
<td>-</td>
|
|
672
|
-
</tr>
|
|
400
|
+
|
|
673
401
|
</tbody>
|
|
674
402
|
</table>
|
|
675
403
|
|
|
@@ -677,53 +405,8 @@ bfsNodes[2].id; // 16
|
|
|
677
405
|
|
|
678
406
|
[//]: # (No deletion!!! Start of Replace Section)
|
|
679
407
|
<div class="json-to-html-collapse clearfix 0">
|
|
680
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
|
|
681
|
-
<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>
|
|
682
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
683
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>binary-tree</span></div>
|
|
684
|
-
<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>
|
|
685
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
686
408
|
<div class='collapsible level0' ><span class='json-to-html-label'>bst</span></div>
|
|
687
409
|
<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>
|
|
688
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
689
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
|
|
690
|
-
<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>
|
|
691
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
692
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>comparison</span></div>
|
|
693
|
-
<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>
|
|
694
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
695
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
|
|
696
|
-
<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>
|
|
697
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
698
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
|
|
699
|
-
<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>
|
|
700
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
701
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
|
|
702
|
-
<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>
|
|
703
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
704
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
|
|
705
|
-
<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>
|
|
706
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
707
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</span></div>
|
|
708
|
-
<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>
|
|
709
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
710
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>max-priority-queue</span></div>
|
|
711
|
-
<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>
|
|
712
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
713
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>priority-queue</span></div>
|
|
714
|
-
<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>
|
|
715
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
716
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
|
|
717
|
-
<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>
|
|
718
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
719
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
|
|
720
|
-
<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>
|
|
721
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
722
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>stack</span></div>
|
|
723
|
-
<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>
|
|
724
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
725
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
|
|
726
|
-
<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>
|
|
727
410
|
</div>
|
|
728
411
|
|
|
729
412
|
[//]: # (No deletion!!! End of Replace Section)
|
|
@@ -753,13 +436,6 @@ bfsNodes[2].id; // 16
|
|
|
753
436
|
</td>
|
|
754
437
|
<td>Iteration</td>
|
|
755
438
|
</tr>
|
|
756
|
-
<tr>
|
|
757
|
-
<td>Graph DFS</td>
|
|
758
|
-
<td>Traverse a graph in a depth-first manner, starting from a given node, exploring along one path as deeply as
|
|
759
|
-
possible, and backtracking to explore other paths. Used for finding connected components, paths, etc.
|
|
760
|
-
</td>
|
|
761
|
-
<td>Recursion + Iteration</td>
|
|
762
|
-
</tr>
|
|
763
439
|
<tr>
|
|
764
440
|
<td>Binary Tree Morris</td>
|
|
765
441
|
<td>Morris traversal is an in-order traversal algorithm for binary trees with O(1) space complexity. It allows tree
|
|
@@ -767,65 +443,6 @@ bfsNodes[2].id; // 16
|
|
|
767
443
|
</td>
|
|
768
444
|
<td>Iteration</td>
|
|
769
445
|
</tr>
|
|
770
|
-
<tr>
|
|
771
|
-
<td>Graph BFS</td>
|
|
772
|
-
<td>Traverse a graph in a breadth-first manner, starting from a given node, first visiting nodes directly connected
|
|
773
|
-
to the starting node, and then expanding level by level. Used for finding shortest paths, etc.
|
|
774
|
-
</td>
|
|
775
|
-
<td>Recursion + Iteration</td>
|
|
776
|
-
</tr>
|
|
777
|
-
<tr>
|
|
778
|
-
<td>Graph Tarjan's Algorithm</td>
|
|
779
|
-
<td>Find strongly connected components in a graph, typically implemented using depth-first search.</td>
|
|
780
|
-
<td>Recursion</td>
|
|
781
|
-
</tr>
|
|
782
|
-
<tr>
|
|
783
|
-
<td>Graph Bellman-Ford Algorithm</td>
|
|
784
|
-
<td>Finding the shortest paths from a single source, can handle negative weight edges</td>
|
|
785
|
-
<td>Iteration</td>
|
|
786
|
-
</tr>
|
|
787
|
-
<tr>
|
|
788
|
-
<td>Graph Dijkstra's Algorithm</td>
|
|
789
|
-
<td>Finding the shortest paths from a single source, cannot handle negative weight edges</td>
|
|
790
|
-
<td>Iteration</td>
|
|
791
|
-
</tr>
|
|
792
|
-
<tr>
|
|
793
|
-
<td>Graph Floyd-Warshall Algorithm</td>
|
|
794
|
-
<td>Finding the shortest paths between all pairs of nodes</td>
|
|
795
|
-
<td>Iteration</td>
|
|
796
|
-
</tr>
|
|
797
|
-
<tr>
|
|
798
|
-
<td>Graph getCycles</td>
|
|
799
|
-
<td>Find all cycles in a graph or detect the presence of cycles.</td>
|
|
800
|
-
<td>Recursion</td>
|
|
801
|
-
</tr>
|
|
802
|
-
<tr>
|
|
803
|
-
<td>Graph getCutVertexes</td>
|
|
804
|
-
<td>Find cut vertices in a graph, which are nodes that, when removed, increase the number of connected components in
|
|
805
|
-
the graph.
|
|
806
|
-
</td>
|
|
807
|
-
<td>Recursion</td>
|
|
808
|
-
</tr>
|
|
809
|
-
<tr>
|
|
810
|
-
<td>Graph getSCCs</td>
|
|
811
|
-
<td>Find strongly connected components in a graph, which are subgraphs where any two nodes can reach each other.
|
|
812
|
-
</td>
|
|
813
|
-
<td>Recursion</td>
|
|
814
|
-
</tr>
|
|
815
|
-
<tr>
|
|
816
|
-
<td>Graph getBridges</td>
|
|
817
|
-
<td>Find bridges in a graph, which are edges that, when removed, increase the number of connected components in the
|
|
818
|
-
graph.
|
|
819
|
-
</td>
|
|
820
|
-
<td>Recursion</td>
|
|
821
|
-
</tr>
|
|
822
|
-
<tr>
|
|
823
|
-
<td>Graph topologicalSort</td>
|
|
824
|
-
<td>Perform topological sorting on a directed acyclic graph (DAG) to find a linear order of nodes such that all
|
|
825
|
-
directed edges go from earlier nodes to later nodes.
|
|
826
|
-
</td>
|
|
827
|
-
<td>Recursion</td>
|
|
828
|
-
</tr>
|
|
829
446
|
</tbody>
|
|
830
447
|
</table>
|
|
831
448
|
|
|
@@ -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": "bst-typed",
|
|
3
|
-
"version": "1.51.
|
|
3
|
+
"version": "1.51.4",
|
|
4
4
|
"description": "BST (Binary Search Tree). Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -144,6 +144,6 @@
|
|
|
144
144
|
"typescript": "^4.9.5"
|
|
145
145
|
},
|
|
146
146
|
"dependencies": {
|
|
147
|
-
"data-structure-typed": "^1.51.
|
|
147
|
+
"data-structure-typed": "^1.51.4"
|
|
148
148
|
}
|
|
149
149
|
}
|
|
@@ -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
|
+
}
|