0

I have difficulty to understand what should the output of the function sort_pairs() should be!, What I understand is I should take the unsorted pairs[] and sort it.

For example, this is pairs[] struct before the sort_pairs() function:

pairs[0].winner = 1;
pairs[0].loser= 0;

pairs[1].winner = 2;
pairs[1].loser= 0;

pairs[2].winner = 1;
pairs[2].loser= 2;

And here is the output:

pairs[0].winner = 2;
pairs[0].loser= 0;

pairs[1].winner = 1;
pairs[1].loser= 2;

pairs[2].winner = 1;
pairs[2].loser= 0;

For more details about the problem set check this

0

It's a void function so it has no output. Per the description:

void sort_pairs(void)
{
    // TODO
}

The function should sort the pairs array in decreasing order of strength of victory, where strength of victory is defined to be the number of voters who prefer the preferred candidate. If multiple pairs have the same strength of victory, you may assume that the order does not matter.

So, your function should sort the global pairs array.

1
  • @curiouakiwi I believe that is the real problem as it seems fresh values from the preferences 2D array would be required to determine strength-of-victory. How then will that be used to sort pairs in order to achieve this order required? The specification also seem very intentionally quiet about this point. – Tosin Coker Feb 17 '20 at 14:54

You must log in to answer this question.

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