Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Check if is One Component | Practice
Breadth First Search
course content

Contenu du cours

Breadth First Search

Breadth First Search

1. What is BFS
2. Practice
3. Improve Your Code
4. Solving the Problems using BFS

book
Check if is One Component

BFS: check if graph is one-component

In the previous method, we considered that the graph is one-component. That’s because if you start traversing at some node, you’ll visit only nodes from the same component.

If there are some other components, you should start from vertices of another component.

Tâche

Swipe to start coding

Think about Implementation of method hasOneComponent(). which returns True if it is only one component in graph.

Modify your g graph by adding nodes in that way, so there are miltiple components, and check how function works.

Solution

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 2
toggle bottom row

book
Check if is One Component

BFS: check if graph is one-component

In the previous method, we considered that the graph is one-component. That’s because if you start traversing at some node, you’ll visit only nodes from the same component.

If there are some other components, you should start from vertices of another component.

Tâche

Swipe to start coding

Think about Implementation of method hasOneComponent(). which returns True if it is only one component in graph.

Modify your g graph by adding nodes in that way, so there are miltiple components, and check how function works.

Solution

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 2
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