A program receives an integer array and rearranges its entries so that every negative entry comes before every nonnegative entry. It must keep every input entry exactly once, including repeated entries. There is no required order within either group. Zero is nonnegative.
We want an automatic check of the result. It has access to both the original input and the output arrays, including their lengths. Array entries are initialized, and either array may be empty.
Check A: compare with a trusted program. Run another program on the original input. That program is guaranteed to produce a correct rearrangement. Accept the output being checked only if it has the same length and agrees with the trusted program’s output at every position.
Check B: check three properties. Accept the output if all three conditions hold:
- It has the same length as the input.
- Every integer value that appears in the output appears at least once in the input.
- No nonnegative output entry appears before a negative output entry.
Assess each check against two goals: accepting every result permitted by the task, and rejecting every result that violates the task. A check might meet both goals, one, or neither.
Then propose an acceptance rule that meets both goals. You may keep either check, change it, or describe another rule. You do not need to write code, make your rule fast, or construct example arrays.
