|
456 | 456 | }, |
457 | 457 |
|
458 | 458 | "OpenHash": { |
459 | | - "Double Hash Add": { |
| 459 | + "Add": { |
460 | 460 | "worst": { |
461 | | - "big_o": "O(n^2)", |
| 461 | + "big_o": "O(n²)", |
462 | 462 | "explanation": "Resize by adding $n$ entries and $n$ probes are needed each", |
463 | 463 | "example": "[null, 0, 1, 2, 3, null, null] add 4, h1 always returns 1, q = 2" |
464 | 464 | }, |
|
473 | 473 | "example": "[0, 1, null, 10, null, null, 6] find 10, q = 11" |
474 | 474 | } |
475 | 475 | }, |
476 | | - "Double Hash Remove": { |
| 476 | + "Remove": { |
477 | 477 | "worst": { |
478 | 478 | "big_o": "O(n)", |
479 | 479 | "explanation": "Collisions cause $n$ probings", |
|
490 | 490 | "example": "[0, 1, null, 10, null, null, 6] find 10, q = 11" |
491 | 491 | } |
492 | 492 | }, |
493 | | - "Double Hash Find": { |
| 493 | + "Find": { |
494 | 494 | "worst": { |
495 | 495 | "big_o": "O(n)", |
496 | 496 | "explanation": "Collisions cause $n$ probings", |
|
627 | 627 | "BubbleSort": { |
628 | 628 | "BubbleSort without Last Swap Optimization": { |
629 | 629 | "worst": { |
630 | | - "big_o": "O(n^2)", |
| 630 | + "big_o": "O(n²)", |
631 | 631 | "explanation": "must swap n data n times each", |
632 | 632 | "example": "[5, 4, 3, 2, 1]" |
633 | 633 | }, |
634 | 634 | "average": { |
635 | | - "big_o": "O(n^2)", |
| 635 | + "big_o": "O(n²)", |
636 | 636 | "explanation": "on average, half data is unsorted thus n/2 swaps for n items", |
637 | 637 | "example": "[1, 4, 3, 5, 2]" |
638 | 638 | }, |
|
644 | 644 | }, |
645 | 645 | "BubbleSort with Last Swap Optimization": { |
646 | 646 | "worst": { |
647 | | - "big_o": "O(n^2)", |
| 647 | + "big_o": "O(n²)", |
648 | 648 | "explanation": "Optimization has not effect on worst case runtime", |
649 | 649 | "example": "[5, 4, 3, 2, 1]" |
650 | 650 | }, |
651 | 651 | "average": { |
652 | | - "big_o": "O(n^2)", |
| 652 | + "big_o": "O(n²)", |
653 | 653 | "explanation": "While optimization does increase average runtime efficiency, it is not enough to affect Big O.", |
654 | 654 | "example": "[1, 4, 3, 5, 2]" |
655 | 655 | }, |
|
664 | 664 | "CocktailSort": { |
665 | 665 | "CocktailSort without Last Swap Optimization": { |
666 | 666 | "worst": { |
667 | | - "big_o": "O(n^2)", |
| 667 | + "big_o": "O(n²)", |
668 | 668 | "explanation": "Must check n times for n items", |
669 | 669 | "example": "[5, 4, 3, 2, 1]" |
670 | 670 | }, |
671 | 671 | "average": { |
672 | | - "big_o": "O(n^2)", |
| 672 | + "big_o": "O(n²)", |
673 | 673 | "explanation": "Must check on average n/2 times for n items", |
674 | 674 | "example": "[1, 4, 3, 5, 2]" |
675 | 675 | }, |
|
681 | 681 | }, |
682 | 682 | "CocktailSort with Last Swap Optimization": { |
683 | 683 | "worst": { |
684 | | - "big_o": "O(n^2)", |
| 684 | + "big_o": "O(n²)", |
685 | 685 | "explanation": "Optimization has no effect on the worst-case runtime", |
686 | 686 | "example": "[5, 4, 3, 2, 1]" |
687 | 687 | }, |
688 | 688 | "average": { |
689 | | - "big_o": "O(n^2)", |
| 689 | + "big_o": "O(n²)", |
690 | 690 | "explanation": "While optimization increases average runtime it is not enough to effect Big O", |
691 | 691 | "example": "[1, 4, 3, 5, 2]" |
692 | 692 | }, |
|
701 | 701 | "InsertionSort": { |
702 | 702 | "InsertionSort": { |
703 | 703 | "worst": { |
704 | | - "big_o": "O(n^2)", |
| 704 | + "big_o": "O(n²)", |
705 | 705 | "explanation": "n checks for each item where there are n items", |
706 | 706 | "example": "[6, 5, 4, 3, 2, 1]" |
707 | 707 | }, |
708 | 708 | "average": { |
709 | | - "big_o": "O(n^2)", |
| 709 | + "big_o": "O(n²)", |
710 | 710 | "explanation": "n/2 checks for each item where there are n items", |
711 | 711 | "example": "[6, 1, 4, 2, 5, 3]" |
712 | 712 | }, |
|
717 | 717 | } |
718 | 718 | } |
719 | 719 | }, |
720 | | - |
| 720 | + |
721 | 721 | "SelectionSort": { |
722 | 722 | "SelectionSort": { |
723 | 723 | "all cases": { |
724 | | - "big_o": "O(n^2)", |
| 724 | + "big_o": "O(n²)", |
725 | 725 | "explanation": "select largest element which is linear time n times", |
726 | 726 | "example": "[7, 1, 8, 3, 5]" |
727 | 727 | } |
|
0 commit comments