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
visited
list: put0
if vertex is not visited yet, or putk
if vertex is ink
th component. - Return tuple of lists of vertex numbers, one list for each component. Create it by using an upgraded
visited
list.
Task
Swipe to start coding
Implement getComponents()
function.
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 5
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
Summarize this chapter
Explain the code in file
Explain why file doesn't solve the task
Awesome!
Completion rate improved to 7.69
Find All Connected Components
Swipe to show menu
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
visited
list: put0
if vertex is not visited yet, or putk
if vertex is ink
th component. - Return tuple of lists of vertex numbers, one list for each component. Create it by using an upgraded
visited
list.
Task
Swipe to start coding
Implement getComponents()
function.
Everything was clear?
Thanks for your feedback!
Awesome!
Completion rate improved to 7.69SectionΒ 2. ChapterΒ 5
single