Solution

ID: past-exam-of-the-computer-science-course-of-the-university-of-oxford/2015/computer-graphics/1/e/solution

After every proposed pixel has passed part (d), insist on exactly one call in every column of the closed endpoint interval:
void final()
{
    for (int x = x0; x <= x1; x++) {
        if (counter[x] != 1) reject();
    }
    accept();
}
Part (d) already rejected every out-of-range column and every incorrect ordinate. A zero counter now detects an omitted column; a counter greater than one detects a repeated call in that column. Because the residual interval in part (d) allows exactly one integer ordinate in each column, accepted calls in a repeated column must address the same pixel. Conversely, a counter of one in every column forces the complete set of nearest pixels, including both endpoints. Consecutive correct columns differ in ordinate by at most one, which proves that there are no gaps in the resulting thin line segment.
The verifier certifies the final plotted set; it need not require calls to arrive in increasing order. Its final condition is simply

New to topics? Read the docs here!