I have been working on the Tideman problem for a while now, and am still not able to find out how to implement the sort_pairs() function.
I have implemented my sort_pairs() function, but it is not working properly, in the sense that it compiles properly, but when I do check50, the red message comes up:
:( sort_pairs sorts pairs of candidates by margin of victory
Here is my pseudo code for the sort_pairs function:
for i = 0 to pair_count
{
for j = 0 to pair_count - i - 1
{
if (preferences[pairs[i].winner][pairs[i].loser] > preferences[pairs[i + 1].loser][pairs[i + 1].winner])
{
swap(pairs[i], pairs[i+1]);
}
}
}
I have done everything I could, but to no avail. Any help would be kindly appreciated.