Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Find All Connected Components | Practice
Breadth First Search

Glissez pour afficher le menu

book
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: put 0 if vertex is not visited yet, or put k if vertex is in kth component.

  • Return tuple of lists of vertex numbers, one list for each component. Create it by using an upgraded visited list.

Tâche

Swipe to start coding

Implement getComponents() function.

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 5

Demandez à l'IA

expand
ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

book
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: put 0 if vertex is not visited yet, or put k if vertex is in kth component.

  • Return tuple of lists of vertex numbers, one list for each component. Create it by using an upgraded visited list.

Tâche

Swipe to start coding

Implement getComponents() function.

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 5
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?
some-alt