Activity 37: Topological Sort and MST
Problem 1A: Topological Sort
Given this DAG (course prerequisites):
CS101 → CS201 → CS301
↓ ↓ ↓
CS150 → CS250 → CS350
↓
CS160
Tasks:
- Trace DFS-based topological sort starting from CS101
- Show the finish order of vertices
- Write the topological ordering (reversed finish order)
- Verify: does your ordering respect all dependencies?
Problem 1B: Minimum Spanning Tree
Given this weighted graph:
A --5-- B --7-- C
| \ | / |
4 6 3 /9 2
| \ |/ |
D --8-- E --4-- F
Choose ONE algorithm to trace:
Option 1: Kruskal's Algorithm
- List all edges sorted by weight
- Mark which edges you add/skip
- Draw the final MST and calculate total weight
Option 2: Prim's Algorithm (start from A)
- Show MST growth step by step
- At each step, show which edge you're adding and why
- Draw the final MST and calculate total weight
Part 2: Create a Challenge
Partner up! Each person should:
-
Design a challenge graph for your partner of your choice:
- Topological sort: Create a DAG with 5-7 vertices
- MST: Create a weighted graph with 5-6 vertices and 7-9 edges
-
Design guidelines:
- Make it interesting but solvable in 3-4 minutes
- For topological sort: ensure it's actually a DAG (no cycles!)
- For MST: include some close edge weights to make decisions non-trivial
- Label your nodes/edges meaningfully! (courses, tasks, roads, etc)
-
Write down your own solution on a separate piece of paper
Part 3: Swap and Solve
- Exchange challenge graphs with your partner
- Solve your partner's problem:
- For topological sort: find a valid ordering
- For MST: trace Kruskal's OR Prim's to find the MST
- Show your work - your partner will check it!
Part 4: Check and Discuss
- Swap back and check each other's solutions using your answer key
- Discuss:
- Did they find a correct solution?
- If topological sort: are there other valid orderings?
- If MST: did you both get the same total weight?
- What made the problem easy or tricky?
Discussion Questions to Submit on Gradescope
- What made a good challenge graph? What made it too easy or too hard?
- Which MST algorithm (Kruskal's or Prim's) felt easier to trace by hand? Why?