Question: Can you help me fix my connected components method? / * * * finds the fewest connected components of a graph * @param ag the

Can you help me fix my connected components method?
/**
* finds the fewest connected components of a graph
* @param ag the AirlineGraph graph representing the airline system
* @return a (possibly empty) Set> of connected components.
* Each connected component is a Set of airport codes in the component.
*/
public Set> connectedComponents(AirlineGraph ag);
Test Failed! Loading routes from file
Your solution: [[DIF],[CLN],[BYB],[UVD, FYE, EAQ, IOZ, WDG, SMF, ELF]] Expected solution: [[CLN],[DIF, UVD, FYE, EAQ, IOZ, BYB, WDG, SMF, ELF]]
This is my output vs what it should be
I was also supposed to use bfs. I have pseudocode,
// Pseudocode
// BFS(vertex v){
// Q = new Queue
// add v to Q
// while(Q is not empty){
// w = remove head of Q
////visit w
// seen[w]= true //mark w as visited
// for each unseen neighbor x
// seen[x]= true //mark x as seen
// add x to Q
//}
//}
Can you help me fix my connected components

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!