0

On Problem Set 3, check50 has flagged my program as not having sorted the pairs correctly. However, the pairs array appears to be sorted in every case I've tried. I used insertion sort and had introduced another global array called strength_of_victory to log the strength of victory between each pair as they are logged in the add_pairs function.

Any reason why it may be detected it as sorted incorrectly?

enter image description here

1

I suspect this "introduced another global array called strength_of_victory" is the problem. Recall from the spec:

You should not modify anything else in tideman.c other than the implementations of the vote, record_preferences, add_pairs, sort_pairs, lock_pairs, and print_winner functions....

2
  • Thank you, I will alter it and see if it works. Seems a little harsh to not allow global variables considering we're allowed to define new functions! But I've been enjoying the ongoing challenges of this problem set. – Gabriel Saul Feb 25 '20 at 19:47
  • Welcome to the real world of team programming. In this world, different people get different parts of the puzzle to develop, so some things absolutely cannot be altered. Otherwise, it leads to chaos when the team puts all the parts together. – Cliff B Feb 25 '20 at 22:13

You must log in to answer this question.

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