Find All Connected Components
BFS find all connected components
Complicate the problem: find all components in a graph.
Some hints for you:
- When you’re done with the first component, save it, and start traversing again with some nodes that haven’t been visited yet.
- To split your components, you can use an upgraded
visitedlist: put0if vertex is not visited yet, or putkif vertex is inkth component. - Return tuple of lists of vertex numbers, one list for each component. Create it by using an upgraded
visitedlist.
Oppgave
Swipe to start coding
Implement getComponents() function.
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 2. Kapittel 5
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 7.69
Find All Connected Components
Sveip for å vise menyen
BFS find all connected components
Complicate the problem: find all components in a graph.
Some hints for you:
- When you’re done with the first component, save it, and start traversing again with some nodes that haven’t been visited yet.
- To split your components, you can use an upgraded
visitedlist: put0if vertex is not visited yet, or putkif vertex is inkth component. - Return tuple of lists of vertex numbers, one list for each component. Create it by using an upgraded
visitedlist.
Oppgave
Swipe to start coding
Implement getComponents() function.
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 2. Kapittel 5
single