New to this platform, forgive me if there are some norm or etiquette I may be missing. Please feel free to provide feedback on anything that is incorrect.

This is for the is-tie function alone. I only get one single error

:( is_tie returns false when only some of the candidates are tied is_tie did not return false

I have tried everything with this function, debugging, printf, and using my notebook. I kind of still don't see the point of the min parameter. A tie is a tie regardless, the function is looking for ties.

Yet the problem is, the function should return false if there aren't too many ties?

bool is_tie(int min)

    bool isTie = false;

    int count = 0;

    int i = 0, j = 1; //I know I reassigned twice, but just to avoid undefined behavior and be able to use printf for debugging

    for (i = 0; i < candidate_count; i++)
        for (j = 1; j < candidate_count - i; j++)
            if (candidates[i].votes == candidates[j + i].votes && candidates[i].votes == min)
                isTie = true;

    //printf("%i", candidates[i].votes);
    //printf("%i", candidates[j+i].votes);

    //printf("%i\n", count);

    return isTie;

full code on https://pastebin.com/M3aHT6EZ

1 Answer 1


According to the spec:

The function should return true if every candidate remaining in the election has the same number of votes, and should return false otherwise.

I interpret the name of the function is_tie to mean all the non-eliminated candidates are tied, not is there a tie between any two candidates. The key word here is every.

The hint says:

Recall that a tie happens if every candidate still in the election has the same number of votes. Note, too, that the is_tie function takes an argument min, which is the smallest number of votes any candidate currently has. How might you use that information to determine if the election is a tie (or, conversely, not a tie)?

The program will proceed to eliminate (which eliminates candidates with min votes) if is_tie returns false. That gives significance to min in the is_tie function. A runoff election always produces (at least one) winner.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .