Problem Solving with Go course

GraphsQuiz: Graphs

Problem Solving with Go

Display

Theme

Graphs · Quiz

Quiz: Graphs

Check what you know about adjacency lists, connected components, Dijkstra, topological sort and tracing a route. Answer every question below.

  1. Question 1 of 6Roads go both ways. What's missing from this code that builds the graph?
    for _, line := range lines {
    	a, b, _ := strings.Cut(line, "-")
    	g[a] = append(g[a], b)
    }
  2. Question 2 of 6A graph has 10 nodes and 6 edges. What is the smallest possible number of connected components?
  3. Question 3 of 6Why can't plain BFS find the cheapest route when roads have different lengths?
  4. Question 4 of 6With container/heap, how do you take the cheapest entry out of q?
  5. Question 5 of 6Kahn's algorithm stops while some steps are still waiting for an earlier step. What does that mean?
  6. Question 6 of 6After Dijkstra with a from map, how do you get the route from start to goal?