Challenge: Implement Breadth-First Graph Traversal

Implement breadth-first traversal with an adjacency list.

Problem statement

We have to implement the breadth-first traversal in C#. It is a level-by-level searching algorithm for the graph, so we will use our already-implemented Graph class for this task (since we have already covered the implementation of the graph).

To solve this problem, all the previously implemented data structures will be available to us.

Input

A graph represented as an adjacency list and a starting vertex.

Output

A string containing the vertices of the graph listed in the correct order of traversal.

Sample input

Graph:

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy