Complete the code to initialize the queue with the start node.
const queue = [[1]];We start BFS by adding the start node to the queue.
Complete the code to mark the start node as visited.
visited[[1]] = true;We mark the start node as visited to avoid revisiting it.
Fix the error in the loop to get the current node from the queue.
const current = queue.[1]();We use shift() to remove the first element from the queue in BFS.
Fill both blanks to check if a neighbor is unvisited and then mark it visited.
if (!visited[neighbor]) { visited[[1]] = true; queue.[2](neighbor); }
We mark the neighbor as visited and add it to the queue using push().
Fill all three blanks to update the distance for neighbors correctly.
distance[neighbor] = distance[[1]] [2] 1; queue.[3](neighbor);
The neighbor's distance is current node's distance plus one, then neighbor is added to the queue.
