Complete the code to initialize the visited array for BFS.
bool[] visited = new bool[[1]];The visited array size should match the number of nodes, which is the length of the graph array.
Complete the code to enqueue the starting node in BFS.
queue.Enqueue([1]);We start BFS from the given startNode, so we enqueue it first.
Fix the error in the BFS loop condition to continue while the queue is not empty.
while (queue.[1] > 0) {
In C#, Queue has a Count property to get the number of elements.
Fill both blanks to mark a node visited and enqueue its neighbors in BFS.
visited[neighbor] = [1]; queue.[2](neighbor);
Mark the neighbor as visited by setting true, then enqueue it using Enqueue method.
Fill all three blanks to complete the BFS function that counts connected components.
for (int i = 0; i < [1]; i++) { if (!visited[i]) { BFS(i, graph, visited); [2]++; } } return [3];
Loop over all nodes using graph.Length, increment count for each BFS call, and return count.
