Embercode
✕
GraphsQuick quiz

Prim and Kruskal

8 questions. Covers Prim's algorithm versus Kruskal's.

Questions 1 to 5 of 8

  1. 1. A complete graph has one edge between every pair of vertices. How many edges does a complete graph with 500 vertices have?

    Type a number.

  2. 2. In the lesson's timing run on a sparse graph with 200000 vertices and 600000 edges, which method was faster, and by roughly how much?
  3. 3. A Prim implementation declares std::priority_queue<Item> heap; and leaves out std::greater<>. Run on the small example from this lesson, what total does it print?
  4. 4. Kruskal calls dsu.unite(a, b) and gets false. What does that mean?
  5. 5. Put these steps of Kruskal's algorithm in the order the code runs them, for one pass over the edges.

    Use the arrows to put the steps in order.

    1. 1.Take the next edge from the sorted list
    2. 2.If unite returned true, add the edge's weight to the total
    3. 3.Call unite on the edge's two ends
    4. 4.Sort every edge by weight, cheapest first

4 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.