Complete the code to declare the adjacency list array for a graph with MAX_VERTICES vertices.
struct Node* adjacencyList[[1]];The adjacency list is an array where each index represents a vertex. The size should be the number of vertices, so MAX_VERTICES is correct.
Complete the code to create a new node for the adjacency list with the given vertex value.
struct Node* newNode = (struct Node*)malloc(sizeof(struct [1]));
newNode->vertex = vertex;
newNode->next = NULL;The node structure is named Node, so we allocate memory for struct Node.
Fix the error in the code that adds an edge from source to destination in the adjacency list.
newNode->next = adjacencyList[[1]];
adjacencyList[source] = newNode;We insert the new node at the head of the list for the source vertex, so the index should be source.
Fill both blanks to complete the function that prints the adjacency list of the graph.
for (int i = 0; i < [1]; i++) { struct Node* temp = adjacencyList[i]; printf("Vertex %d:", i); while (temp != [2]) { printf(" -> %d", temp->vertex); temp = temp->next; } printf("\n"); }
The loop runs from 0 to MAX_VERTICES to cover all vertices. The end of the linked list is marked by NULL.
Fill all three blanks to complete the function that adds an undirected edge between two vertices.
void addEdge(int src, int dest) {
struct Node* newNode = (struct Node*)malloc(sizeof(struct [1]));
newNode->vertex = dest;
newNode->next = adjacencyList[src];
adjacencyList[src] = newNode;
newNode = (struct Node*)malloc(sizeof(struct [2]));
newNode->vertex = src;
newNode->next = adjacencyList[[3]];
adjacencyList[dest] = newNode;
}Both nodes are of type Node. The second new node is added to the adjacency list of dest, so the index is dest.