Complete the code to declare a 2D adjacency matrix for 4 nodes initialized with zeros.
int adjMatrix[4][4] = [1];
The adjacency matrix for 4 nodes is a 4x4 2D array initialized with zeros to indicate no edges.
Complete the code to set an edge from node 1 to node 3 in the adjacency matrix.
adjMatrix[1][[1]] = 1;
Node indexing starts at 0, so node 3 corresponds to index 2.
Fix the error in the code to correctly check if there is an edge from node 0 to node 2.
if (adjMatrix[0][2] [1]) { // edge exists }
Use '==' to compare values, '=' is assignment and causes a bug.
Fill both blanks to correctly print all edges from node 2.
for (int [1] = 0; [2] < 4; [1]++) { if (adjMatrix[2][[1]] == 1) { std::cout << "Edge from 2 to " << [1] << std::endl; } }
Use the same loop variable 'i' for initialization and condition to iterate over columns.
Fill all three blanks to create an adjacency matrix for 3 nodes and add an edge from node 0 to node 1.
int [1][[2]][[3]] = {{0}}; adjMatrix[0][1] = 1;
Declare a 3x3 adjacency matrix named adjMatrix initialized with zeros.
