6.24 Common Bugs
Identify boundary errors, broken invariants, and comparator mistakes that cause sorting implementations to fail on edge cases or duplicate-heavy inputs.
6 notes
Identify boundary errors, broken invariants, and comparator mistakes that cause sorting implementations to fail on edge cases or duplicate-heavy inputs.
Verify both the ordering and permutation properties of sorting implementations using randomized, edge-case, and adversarial test strategies.
Define correct comparison relations for user-defined types and non-trivial orderings — consistency requirements that sorting correctness depends on.
A sorting algorithm is correct only when its output is both ordered and a permutation of the input — two properties every implementation must preserve.
Verify correctness, stability, and performance of hash-based structures through randomized and adversarial test strategies.
Loop invariants are the primary tool for reasoning about iterative algorithms.