can anyone please help I got only one error which is:-
lock_pairs skips final pair if it creates cycle lock_pairs did not correctly lock all non-cyclical pairs
and this is my code
bool hash_cycle(int index, bool visited[])
{
if(visited[index])
{
return true;
}
visited[index] = true;
for(int i = 0; i < pair_count; i++)
{
if(locked[index][i] && hash_cycle(i, visited))
{
return true;
}
}
return false;
}
bool cycle(int index)
{
bool visited[pair_count];
for (int i = 0; i < pair_count; i++)
{
visited[i] = false;
}
return hash_cycle(index, visited);
}
// Lock pairs into the candidate graph in order, without creating cycles
void lock_pairs(void)
{
// TODO
for (int i = 0; i < pair_count; i++)
{
locked[pairs[i].winner][pairs[i].loser] = true;
if (cycle(i))
{
locked[pairs[i].winner][pairs[i].loser] = false;
}
}
}