Complete the code to declare the queue size for BFS traversal.
int queue[[1]];The queue size should be large enough to hold all nodes. Using 1000 ensures enough space for BFS.
Complete the code to mark a node as visited inside BFS.
visited[[1]] = 1;
We mark the node at the front of the queue as visited after dequeuing it.
Fix the error in the BFS enqueue operation to add neighbors.
if(adj[node][i] == 1 && visited[i] == 0) { queue[[1]] = i; rear++; visited[i] = 1; }
We add the neighbor at the rear of the queue before incrementing rear.
Fill both blanks to correctly initialize BFS queue pointers.
int front = [1]; int rear = [2];
Front starts at 0 and rear starts at -1 before any elements are enqueued.
Fill all three blanks to complete the BFS loop condition and dequeue operation.
while([1] <= [2]) { int node = queue[[3]]; front++; // process node }
The BFS loop runs while front <= rear. We dequeue from queue[front].
