The output of a sorting algorithm must be a permutation of the complete input sequence. For equal lengths , require a permutation of such that
Equivalently, the input and output have the same multiset of complete entries: each entry has the same multiplicity. Equality of the underlying sets is insufficient; and have the same set of values and the same length but different multisets. When tracking occurrences rather than contents, retain original identity labels to check that each one is moved exactly once. A swap preserves this multiset automatically; an overwrite need not.
Test case 2026-11-05
A test case specifies conditions, inputs, an operation to perform and the expected result or acceptance property for software testing. Its test oracle must distinguish success from failure.[ref] Merely executing a computer program without checking an outcome supplies weaker evidence.
For example, a sorting algorithm given 3,1,3 should return 1,3,3. A stronger test oracle checks both sortedness and preservation of the input multiset; checking only sortedness would accept an empty result. The test case also needs a policy for equal elements if their original order matters. Explicit preconditions and expected outcomes make a failure reproducible and help a later reader understand which contract the test case exercises.
Test oracle 2026-11-05
A test oracle determines whether an observed test result is acceptable. It can be an explicitly expected output, a mathematical property, a trusted reference implementation or another justified source of comparison. Generating many inputs without an oracle does not by itself establish whether the results are correct.
For a sorting routine, an oracle can check both sortedness and preservation of the input multiset. Returning an empty sequence passes a sortedness check but fails preservation for a nonempty input. A differential test instead compares implementations; a disagreement exposes a problem without necessarily identifying which implementation is wrong. Hypothesis documents both reference-oracle comparisons and differential comparisons in its equivalence-test generator.[ref]
Trie search with a letter multiset Created 2026-10-31 Updated 2026-11-05
Use backtracking through a dictionary trie, decrementing and restoring the available count for each traversed letter. Visit each letter-labelled child once when its count is positive, rather than choosing between indistinguishable occurrences. Every reachable complete word is then produced once, including words using only a subcollection of the original letter multiset.
Two-way array partition Created 2026-10-24 Updated 2026-10-31
Rearrange an array segment into a low segment containing values below a pivot and a high segment containing values at least , preserving the segment's multiset and leaving the rest of the array unchanged. The pivot need not itself occur, and either resulting segment may be empty.
An in-place scan maintains indices with and . A low value at is swapped into position and advances both indices; a high value advances only . The unexamined length is a loop variant. At exit , establishing the separation in time complexity and auxiliary space complexity. Equal values consistently belong to the high side.
An elementary union-intersection compression of a finite multiset of subsets replaces occurrences of by . A compression is a finite sequence of these moves. The move preserves every coordinate multiplicity. On incomparable sets it increases by , so repeated compression reaches a chain under inclusion. For any submodular set function, the sum of its values cannot increase.
Unordered pair Created 2026-09-24 Updated 2026-11-05
An unordered pair is a set containing the specified elements, with no distinction between first and second positions. Hence . If , the notation denotes the singleton , rather than a two-element set.
For distinct , an unordered pair represents an edge in a simple undirected graph. An ordered pair instead represents a directed edge because reversing its entries changes the direction. If multiplicity must be retained even for equal elements, a multiset is needed instead of a set.