I was doing the tideman problem in pset3(cs50), but I can't tell the difference between my programme and the correct programme of the function look\_pairs.

```
:) tideman.c exists
:) tideman compiles
:) vote returns true when given name of candidate
:) vote returns false when given name of invalid candidate
:) vote correctly sets rank for first preference
:) vote correctly sets rank for all preferences
:) record_preferences correctly sets preferences for first voter
:) record_preferences correctly sets preferences for all voters
:) add_pairs generates correct pair count when no ties
:) add_pairs generates correct pair count when ties exist
:) add_pairs fills pairs array with winning pairs
:) add_pairs does not fill pairs array with losing pairs
:) sort_pairs sorts pairs of candidates by margin of victory
:) lock_pairs locks all pairs when no cycles
:( lock_pairs skips final pair if it creates cycle
    lock_pairs did not correctly lock all non-cyclical pairs
:) lock_pairs skips middle pair if it creates a cycle
:) print_winner prints winner of election when one candidate wins over all others
:) print_winner prints winner of election when some pairs are tied

```

This is my programme, I made a little difference between the correct one.Instead of judging the return of the makeCycle(winner, i), I just return this function, you can see the difference in my code.

```
bool makeCycle(int winner, int loser) 
{
        if (winner == loser) {
            return true;
        }
        for (int i = 0; i < candidate_count; i ++) {
            if (locked[loser][i]) {
                    return makeCycle(winner, i); 
            }
        }
        return false;
}

// Lock pairs into the candidate graph in order, without creating cycles
void lock_pairs(void)
{
    // TODO
    for(int i = 0; i < candidate_count; i ++) {
        if (!makeCycle(pairs[i].winner, pairs[i].loser)) {
            locked[pairs[i].winner][pairs[i].loser] = true;
        }
    }
    return;
}

```

This is the correct version, but I think my programm is the same as the correct version, I don't know why my programme will cause this mistake.

```
bool makeCycle(int winner, int loser) 
{
        if (winner == loser) {
            return true;
        }
        for (int i = 0; i < candidate_count; i ++) {
            if (locked[loser][i]) {
                    if(makeCycle(winner, i)){
                        return true;
                    }
            }
        }
        return false;
}

// Lock pairs into the candidate graph in order, without creating cycles
void lock_pairs(void)
{
    // TODO
    for(int i = 0; i < candidate_count; i ++) {
        if (!makeCycle(pairs[i].winner, pairs[i].loser)) {
            locked[pairs[i].winner][pairs[i].loser] = true;
        }
    }
    return;
}```

```