0

Is it required to eliminate candidates within the tabulate function? How should we recognize when a candidate is eliminated and how do we go about increasing vote count catering for eliminated candidates and votes other than first preferences?

1 Answer 1

1

Q: Is it required to eliminate candidates within the tabulate function?

A: No. That is done in the eliminate function

Q: How should we recognize when a candidate is eliminated

A: From the spec hints:

Recall that the candidate struct has a field called eliminated, which will be true if the candidate has been eliminated from the election.

Q: how do we go about increasing vote count catering for eliminated candidates and votes other than first preferences?

A: Also from the spec hints:

Once you’ve cast a vote for a voter’s first non-eliminated candidate, you’ll want to stop there, not continue down their ballot! Recall that you can break out of a loop early using break inside of a conditional.

It might be confusing because of the dependencies, ie tabulate needs to know the value of eliminated. Have a look at where the candidates struct is created; eliminated defaults to false.

for (int i = 0; i < candidate_count; i++)
{
    candidates[i].name = argv[i + 1];
    candidates[i].votes = 0;
    candidates[i].eliminated = false;
}

You must log in to answer this question.

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