{
  "format": "recallweave-deck/1",
  "title": "Minimum spanning forests: connect without cycles",
  "attribution": "Original questions, worked examples, guide and diagrams for RecallWeave, 2026. Algorithm background: Robert Sedgewick and Kevin Wayne, Algorithms 4/e, KruskalMST documentation (https://algs4.cs.princeton.edu/code/javadoc/edu/princeton/cs/algs4/KruskalMST.html); MIT OpenCourseWare 6.046J, Lecture 12, Greedy Algorithms: Minimum Spanning Tree, Spring 2015 (https://ocw.mit.edu/courses/6-046j-design-and-analysis-of-algorithms-spring-2015/resources/lecture-12-greedy-algorithms-minimum-spanning-tree/). No source exercises, prose, code or figures are reproduced.",
  "license": "CC0-1.0 for this original course content. Referenced materials retain their own terms and are not included in this deck.",
  "concepts": [
    "The spanning objective",
    "Safe edge choices",
    "Components and cycles",
    "Reading the result"
  ],
  "items": [
    {
      "id": "msf-objective",
      "concept": "The spanning objective",
      "prerequisites": [],
      "prompt": "A weighted undirected graph represents available links. What does a minimum spanning tree minimize when the graph is connected?",
      "options": [
        "The total weight of the chosen cycle-free links connecting every vertex.",
        "The length of every route between every pair of vertices simultaneously.",
        "The number of vertices that need to be connected.",
        "The weight of the single largest input edge, even if vertices remain disconnected."
      ],
      "answer": 0,
      "explanation": "A spanning tree includes every vertex, stays connected and has no cycle. Among those trees, a minimum spanning tree has the smallest sum of chosen edge weights. There are no directed arrows or chosen start vertex in this problem.",
      "transfer": "Suppose a network has four vertices. Every spanning tree has three edges, so counting its edges alone cannot choose the minimum-weight tree. Compare the sums of their edge weights."
    },
    {
      "id": "msf-not-shortest",
      "concept": "The spanning objective",
      "prerequisites": [],
      "prompt": "A triangle has edges A–B weight 2, B–C weight 2 and A–C weight 3. A minimum spanning tree chooses A–B and B–C. Which statement about a trip from A to C is correct?",
      "options": [
        "Its tree route has weight 2, because each chosen edge weighs 2.",
        "Its tree route weighs 4, although the original graph has a direct route weighing 3.",
        "Its tree route weighs 3, because a minimum spanning tree always keeps every shortest route.",
        "The tree cannot contain C because the direct A–C edge was omitted."
      ],
      "answer": 1,
      "explanation": "The tree's A→B→C route uses two weight-2 edges, for a total of 4. The original graph also has a direct A–C edge of weight 3. The tree minimizes the total cost of connecting all vertices: 2 + 2 = 4, rather than either alternative tree's 5. That objective does not minimize every individual route.",
      "transfer": "If the task changes to finding the cheapest route from a chosen start vertex, the objective has changed. A shortest-path method addresses that task; selecting a minimum spanning tree first does not generally preserve its answer."
    },
    {
      "id": "msf-undirected",
      "concept": "The spanning objective",
      "prerequisites": [],
      "prompt": "This explorer accepts a simple undirected graph. You enter 'A B 2', then 'B A 5'. Why must it refuse that pair of lines?",
      "options": [
        "Undirected graphs require all weights to be equal.",
        "The letter B must always come after A in every input line.",
        "Both lines name the same unordered vertex pair; this explorer excludes parallel edges.",
        "A graph may contain only one edge in total."
      ],
      "answer": 2,
      "explanation": "In an undirected graph, A–B and B–A connect the same pair. The explorer deliberately permits at most one edge per unordered pair, so these two lines are a duplicate even though their weights differ. A single line may use either endpoint order. This is an input convention for this bounded explorer, not a claim that all graph algorithms exclude parallel edges.",
      "transfer": "Entering only 'B A 2' is valid and preserves that orientation in the trace record. The decision still tests whether A and B are already connected; reversing a single edge does not make it directed."
    },
    {
      "id": "msf-weight-order",
      "concept": "Safe edge choices",
      "prerequisites": [
        "The spanning objective"
      ],
      "prompt": "Input lines are A–B weight 4, A–C weight 1, B–C weight 2, B–D weight 5, C–D weight 3. Kruskal's rule inspects edges from smallest weight to largest. Which sequence is inspected?",
      "options": [
        "A–B, A–C, B–C, B–D, C–D.",
        "A–B, B–C, C–D, A–C, B–D.",
        "B–D, A–B, C–D, B–C, A–C.",
        "A–C, B–C, C–D, A–B, B–D."
      ],
      "answer": 3,
      "explanation": "The weights in inspection order are 1, 2, 3, 4 and 5. Inspection order is a global order over the edges; it is not a walk starting at A. For this graph, the first three edges connect all four vertices without a cycle. The final two edges are inspected and rejected in this explorer's complete trace.",
      "transfer": "Change A–B from weight 4 to weight 0 while keeping every other line fixed. A–B becomes the first edge inspected. Rebuild the trace after changing an input; a trace for the old weights is no longer evidence for the new graph."
    },
    {
      "id": "msf-cut-choice",
      "concept": "Safe edge choices",
      "prerequisites": [
        "The spanning objective"
      ],
      "prompt": "The accepted edges currently connect A and B in one component. No accepted edge leaves that component. Available crossing edges have weights 2, 5 and 7. Why can a lightest crossing edge of weight 2 be a safe next connection in Kruskal's process?",
      "options": [
        "It joins two components, and the cut property allows a lightest edge across this component boundary in some minimum spanning forest extending the accepted forest.",
        "Every edge crossing any component boundary must appear in every minimum spanning tree.",
        "Its weight is positive, which makes cycle checks unnecessary.",
        "It guarantees the shortest route from A to every remaining vertex."
      ],
      "answer": 0,
      "explanation": "The boundary separates {A, B} from the other vertices, and no already accepted edge crosses it. A lightest edge across that boundary is compatible with a minimum spanning forest extending the accepted choices. If it is already in a compatible minimum forest, no exchange is needed. Otherwise add it: inside its original connected component, this creates a cycle. Remove another crossing edge of at least the chosen weight to retain a minimum forest containing the chosen edge. Kruskal combines weight order with the rule that a newly accepted edge must join different components.",
      "transfer": "If two crossing edges both have the smallest weight, either may be a safe choice. That does not mean both must be included: adding later edges still needs a cycle check. A tie can produce different minimum spanning forests with the same total weight."
    },
    {
      "id": "msf-negative",
      "concept": "Safe edge choices",
      "prerequisites": [
        "The spanning objective"
      ],
      "prompt": "Edges are A–B weight −4, B–C weight −2, A–C weight 1, C–D weight 3 and A–D weight 9. Which minimum spanning tree total follows the weight order and cycle rule?",
      "options": [
        "0, because negative weights must be discarded.",
        "−3, from A–B, B–C and C–D.",
        "−6, from A–B and B–C, leaving D out.",
        "7, from A–C, C–D and A–D."
      ],
      "answer": 1,
      "explanation": "Accept A–B (−4), then B–C (−2). A–C would close a cycle, so reject it. Accept C–D (3) to connect D, then reject A–D. The total is −4 − 2 + 3 = −3. Negative and zero weights are valid for this spanning-tree objective; the tree still has to connect every vertex and remain cycle-free.",
      "transfer": "Change C–D's weight from 3 to 0. The same three edges are accepted and the total becomes −6. The negative values do not authorize omitting D or adding a cycle."
    },
    {
      "id": "msf-cycle",
      "concept": "Components and cycles",
      "prerequisites": [
        "Safe edge choices"
      ],
      "prompt": "The accepted edges are A–B and B–C. The next inspected edge is A–C. What should the explorer do?",
      "options": [
        "Accept it, because it names a different pair from either accepted edge.",
        "Accept it whenever its weight is nonnegative.",
        "Reject it, because A and C already have a path through B.",
        "Reject it only if A and C have the same letter."
      ],
      "answer": 2,
      "explanation": "The accepted path A→B→C already joins A to C. Adding A–C would close the cycle A–B–C–A. A cycle check compares connected components, not just whether an identical edge was previously selected. A rejected edge leaves the accepted set, component count and cumulative weight unchanged.",
      "transfer": "If the next edge were C–D and D were isolated, it would join different components and be accepted. That acceptance decreases the number of components by exactly one."
    },
    {
      "id": "msf-tie-order",
      "concept": "Components and cycles",
      "prerequisites": [
        "Safe edge choices"
      ],
      "prompt": "A triangle's three input lines are A–C weight 1, A–B weight 1, B–C weight 1, in that order. This explorer breaks equal-weight ties by original input line order. Which edges are accepted?",
      "options": [
        "All three, because equal weights cannot form a cycle.",
        "Only A–C, because no later edge has a smaller weight.",
        "A–B and B–C, because the letters must be sorted alphabetically.",
        "A–C and A–B; B–C is then rejected."
      ],
      "answer": 3,
      "explanation": "All weights tie, so inspect A–C first and A–B second. Both connect different components. All three vertices are then connected, so B–C would close a cycle and is rejected. The total is 2. Input order makes this trace reproducible; it is not a proof that this is the only minimum tree.",
      "transfer": "Put B–C first, then A–B, then A–C. The accepted edges change to B–C and A–B while the total remains 2. A deterministic tie policy chooses one valid answer from potentially several."
    },
    {
      "id": "msf-component-snapshot",
      "concept": "Components and cycles",
      "prerequisites": [
        "Safe edge choices"
      ],
      "prompt": "There are five vertices A, B, C, D and E. The accepted edges are A–C and B–D. Which connected-component snapshot is correct, including isolated vertices?",
      "options": [
        "{A, C}, {B, D}, {E}.",
        "{A, B, C, D}, {E}.",
        "{A, C}, {B, D}; E does not count.",
        "{A}, {B}, {C}, {D}, {E}, because no cycles have formed."
      ],
      "answer": 0,
      "explanation": "A–C joins A with C, and B–D joins B with D. There is no selected path connecting those two pairs. E is an isolated component and must remain visible. Components describe reachability using the edges accepted so far, not geometric proximity in the drawing.",
      "transfer": "Accepting C–E merges {A, C} with {E}, leaving {A, C, E} and {B, D}. A line crossing another line in the drawing does not create a graph vertex or connection unless an endpoint says so."
    },
    {
      "id": "msf-disconnected",
      "concept": "Reading the result",
      "prerequisites": [
        "Components and cycles"
      ],
      "prompt": "For vertices A through E, the available edges are A–B weight 1, B–C weight 2, A–C weight 4 and D–E weight −2. There is no edge between {A, B, C} and {D, E}. What is the final result?",
      "options": [
        "A spanning tree over all five vertices, with total 1.",
        "A minimum spanning forest with two components, three accepted edges and total 1.",
        "A spanning tree over A, B and C only, with total 3; D and E are discarded.",
        "No valid result, because disconnected graphs cannot have forests."
      ],
      "answer": 1,
      "explanation": "Accept D–E (−2), A–B (1) and B–C (2); reject A–C because it closes a cycle. The total is −2 + 1 + 2 = 1. Each original connected component has its own minimum spanning tree. No available edge can join the two components, so the result is a forest, not a spanning tree over all five vertices.",
      "transfer": "Add an isolated F with no new edges. The accepted edges and total stay the same, but there are now three components. For a spanning forest with n vertices and k components, the accepted edge count is n − k: 6 − 3 = 3 here."
    },
    {
      "id": "msf-singleton",
      "concept": "Reading the result",
      "prerequisites": [
        "Components and cycles"
      ],
      "prompt": "The input has one vertex A and no edges. Which result follows this explorer's conventions?",
      "options": [
        "One rejected edge, total 0 and two components.",
        "No result until a self-loop is added.",
        "A connected one-vertex tree with zero edges, total 0 and zero edge decisions.",
        "A disconnected result because every vertex needs a neighboring vertex."
      ],
      "answer": 2,
      "explanation": "A is already the only connected component. A one-vertex graph is connected, and its empty edge set is a tree with total weight 0. There are no edges to inspect, so there are zero decisions. A self-loop is neither necessary nor accepted by this simple-graph input.",
      "transfer": "Choose three vertices with no edges. The result has three isolated components and remains a minimum spanning forest with zero edges and total 0. It is not a connected tree."
    },
    {
      "id": "msf-count",
      "concept": "Reading the result",
      "prerequisites": [
        "Components and cycles"
      ],
      "prompt": "A connected graph has four vertices and five input edges. This explorer records a decision for every edge, even after a tree has formed. How many accepted edges and total edge decisions does its completed trace contain?",
      "options": [
        "Five accepted edges and five decisions.",
        "Three accepted edges and three decisions.",
        "Four accepted edges and five decisions.",
        "Three accepted edges and five decisions."
      ],
      "answer": 3,
      "explanation": "A tree over four vertices has 4 − 1 = 3 accepted edges. The remaining two input edges are rejected because their endpoints are already connected when they are inspected. This explorer deliberately records all five decisions. That count is not the number of sorting comparisons, component lookups, input-validation operations or rendering operations.",
      "transfer": "Some implementations stop once n − 1 edges have been accepted in a connected graph. This explorer continues to show why every remaining edge is excluded. Compare algorithms only after stating exactly what is being counted."
    }
  ]
}
