Complete the code to declare an adjacency list as a map of slices.
adjList := make(map[int][1])The adjacency list stores neighbors as slices of integers, so the map value type should be []int.
Complete the code to add an edge from node 1 to node 2 in the adjacency list.
adjList[1] = append(adjList[1], [1])
To add an edge from node 1 to node 2, append 2 to the slice at adjList[1].
Fix the error in the code to correctly initialize the adjacency list for 3 nodes.
adjList := make(map[int][1]) for i := 1; i <= 3; i++ { adjList[i] = [2]{} }
The map values must be slices of int ([]int). Initialize each node's adjacency slice as an empty []int.
Fill both blanks to add edges from node 2 to nodes 1 and 3.
adjList[2] = append(adjList[2], [1]) adjList[2] = append(adjList[2], [2])
To add edges from node 2 to nodes 1 and 3, append 1 and 3 to adjList[2].
Fill all three blanks to print all neighbors of node 1 using a for loop.
for _, [1] := range adjList[1] { fmt.[2]([3]) }
Use 'neighbor' as the variable name, fmt.Println to print, and print the neighbor variable.
