Quiz 5 Practice - Reductions & Max Flow

Focused Practice for Maximum Flow and NP-Completeness

Instructions

Format: Matches Quiz 5 structure exactly

Total Points: 100 points

Note: This practice quiz mirrors the actual Quiz 5 format. Questions focus on max flow residual graphs, Ford-Fulkerson vs Edmonds-Karp paths, reduction logic, bipartite graphs, and NP-completeness. Answers limited to 20 words for theory questions.

Question 1: Maximum Flow Residual Graph (24 points)

Consider the following flow network G. Vertices are labeled by single letters. Edges are labeled with flow/capacity notation.

s a b c d e t sa: 4/8 sb: 6/10 ac: 3/6 ad: 1/4 bd: 5/7 bc: 1/3 ce: 4/9 de: 6/8 et: 10/12

Note: Edges are processed in alphabetical order. No algorithm will traverse the same edge twice.

Determine edge weights for the residual graph GR using the standard residual graph algorithm. Write your answers in the table below. The second row with R edges (saR, sbR, etc.) are for flow in the reverse direction. List only the flow (single integer), not capacity.

sasbacadbcbdcedeet
         
saRsbRacRadRbcRbdRceRdeRetR
         
Question 2: Path Classification - Ford-Fulkerson vs Edmonds-Karp (33 points)

Using the residual graph GR from Question 1, evaluate each potential path and classify it:

Classification Options:

  • A) Path that could be found by both FF and EK
  • B) Path that could be found by FF, but would not be found by EK
  • C) Path that would not be found by FF, but could be found by EK
  • D) Path would not be found by either FF or EK
  • E) This is not a valid path in this residual graph

Remember: We're asking about augmenting paths in GR, not all possible paths in G!

Path A B C D E
s → a → c → e → t ○○○○○
s → b → d → e → t ○○○○○
s → a → d → e → t ○○○○○
s → b → c → e → t ○○○○○
s → a → c → eR → d → et ○○○○○
s → b → bdR → ac → ce → t ○○○○○
s → a → ad → de → et ○○○○○
s → sbR → sa → ac → ce → t ○○○○○
s → b → d → deR → ce → t ○○○○○
s → a → b → c → e → t ○○○○○
s → b → bc → ce → et ○○○○○
Question 3: Problem Reduction Logic (20 points)

Assume you can reduce problem A to problem B in polynomial time. Fill in the table with what you can infer from the property in the first column. If you can't infer anything, write "nothing".

If this is true Then you can infer:
We know A must be slow (hard)
We know A is fast (easy)
We know B must be slow (hard)
We know B is fast (easy)
Question 4: Bipartite Graph Identification (5 points)

Which of the following is an example of a bipartite graph?

Question 5: NFA Diagram (10 points)

Draw a diagram of an NFA (non-deterministic finite automata) that accepts strings containing at least one '0' followed eventually by at least one '1'. Your diagram should:

  • Include labeled states (circles)
  • Show transitions with arrows
  • Label transitions with the input symbol (0, 1, or ε)
  • Indicate start state and accept/final state(s)
  • Be as small as possible (minimize states)
Questions 6-8: Complexity Classes (24 points)

Word Limit: Each answer must be 20 words or fewer. Longer answers receive zero credit.

Question 6 [8 points]

What does it mean if a problem X is in the complexity class P?

Question 7 [8 points]

What does it mean if a problem X is in the complexity class NP?

Question 8 [8 points]

Consider the complexity classes P and NP. Why is P ⊆ NP?

Question 9: NP-Complete Explanation (9 points)

Explain, in English, what NP-complete means (or what an NP-complete problem is). This should be an explanation geared toward somebody with no computing or relevant mathematical experience. (20 words maximum)

Question 10: Proving NP-Completeness (10 points)

What step(s) are typically done to show that a problem is NP-complete? Fill in all that apply. (This answer can be up to 30 words, but no more!)

DETAILED ANSWER KEY - QUIZ 5 PRACTICE

Every answer includes complete step-by-step explanations with NO ambiguity.

Question 1: Residual Graph (24 points)

Forward Edges (remaining capacity = capacity - current_flow):
sasbacadbcbdcedeet
443322522
Reverse Edges (current_flow that can be pushed back):
saRsbRacRadRbcRbdRceRdeRetR
4631154610

Step-by-step calculation:

  • sa: capacity=8, flow=4 → forward=8-4=4, reverse=4
  • sb: capacity=10, flow=6 → forward=10-6=4, reverse=6
  • ac: capacity=6, flow=3 → forward=6-3=3, reverse=3
  • ad: capacity=4, flow=1 → forward=4-1=3, reverse=1
  • bc: capacity=3, flow=1 → forward=3-1=2, reverse=1
  • bd: capacity=7, flow=5 → forward=7-5=2, reverse=5
  • ce: capacity=9, flow=4 → forward=9-4=5, reverse=4
  • de: capacity=8, flow=6 → forward=8-6=2, reverse=6
  • et: capacity=12, flow=10 → forward=12-10=2, reverse=10

Total flow verification: Flow out of s = 4+6 = 10, Flow into t = 10 ✓

Question 2: Path Classification (33 points)

Path-by-path analysis:
  1. s → a → c → e → t
    • Length: 4 edges
    • Valid path? Check capacities: sa(4), ac(3), ce(5), et(2) - all > 0 ✓
    • EK finds shortest paths (BFS). Is there a shorter path? Yes - any 3-edge path
    • FF can find any valid path, including this one
    • ANSWER: B (FF yes, EK no - too long)
  2. s → b → d → e → t
    • Length: 4 edges
    • Valid: sb(4), bd(2), de(2), et(2) - all > 0 ✓
    • Longer than shortest paths (3 edges exist)
    • ANSWER: B (FF yes, EK no)
  3. s → a → d → e → t
    • Length: 4 edges
    • Valid: sa(4), ad(3), de(2), et(2) - all > 0 ✓
    • Not shortest path
    • ANSWER: B (FF yes, EK no)
  4. s → b → c → e → t
    • Length: 4 edges
    • Check edge s→b: exists ✓, b→c: exists ✓, c→e: exists ✓, e→t: exists ✓
    • Capacities: sb(4), bc(2), ce(5), et(2) - all > 0 ✓
    • Not shortest (3-edge paths exist)
    • ANSWER: B (FF yes, EK no)
  5. s → a → c → eR → d → et
    • Invalid notation: "et" at end should be "e → t"
    • Path uses reverse edge eR (pushing flow back on ce)
    • Even if corrected to s→a→c→eR→... this doesn't make sense (can't go from c to e backwards then continue)
    • ANSWER: E (not a valid path)
  6. s → b → bdR → ac → ce → t
    • Invalid: Can't go from b to bdR (bdR is d→b reverse edge)
    • This notation suggests going backwards on bd then jumping to ac, which doesn't form a valid s-to-t path
    • ANSWER: E (not a valid path)
  7. s → a → ad → de → et
    • Invalid notation: edges are denoted by vertex pairs, not "ad", "de", "et" as intermediate vertices
    • If interpreted as s→a→d→e→t: valid, length 4, not shortest
    • With literal interpretation: ANSWER: E (notation error)
    • If generous: ANSWER: B
  8. s → sbR → sa → ac → ce → t
    • Invalid: sbR is b→s (reverse), can't go from s to sbR
    • ANSWER: E (not a valid path)
  9. s → b → d → deR → ce → t
    • Path: s→b→d, then deR (d→e backwards becomes e→d backwards?), then ce→t
    • Invalid structure - can't go forward on d then use deR
    • ANSWER: E (not a valid path)
  10. s → a → b → c → e → t
    • Check edge a→b: NO such edge in original graph! Only b→c, not a→b
    • ANSWER: E (edge a→b doesn't exist)
  11. s → b → bc → ce → et
    • Interpret as s→b→c→e→t: length 4, valid path
    • Capacities: sb(4), bc(2), ce(5), et(2) - all > 0 ✓
    • Not shortest path
    • ANSWER: B (FF yes, EK no)

Key Insights:

  • Answer C is impossible: EK is a specific implementation of FF using BFS. Any path EK finds, FF can also find. C would require EK to find something FF cannot, which violates the algorithm relationship.
  • Shortest paths from s to t: Any path with 3 edges would be found by EK
  • FF can find any valid augmenting path, including longer ones

Question 3: Reduction Logic (20 points)

Given: A reduces to B in polynomial time (A ≤p B)

Key principle: If A ≤p B, then solving B solves A. Therefore:

  • If B is easy, then A must be easy (because we can solve A using B)
  • If A is hard, then B must be hard (because making B easy would make A easy)
If this is true Then you can infer:
We know A must be slow (hard) B must also be slow (hard)
Reason: If B were fast, we could solve A in polynomial time (reduction + B's time), contradicting that A is slow.
We know A is fast (easy) Nothing
Reason: B could be either fast or slow. A being easy doesn't tell us anything about B's difficulty.
We know B must be slow (hard) Nothing
Reason: A could be either easy or hard. B being hard doesn't constrain A.
We know B is fast (easy) A must also be fast (easy)
Reason: We can solve A by reducing to B (polynomial time) then solving B (fast), so total time is fast.

Memory aid: Information flows "upstream" against the reduction arrow direction. If you know something about A (the source), it tells you about B (the target) if A is hard. If you know about B, it tells you about A if B is easy.

Question 4: Bipartite Graph (5 points)

ANSWER: C

Explanation: A bipartite graph has vertices that can be divided into two disjoint sets such that every edge connects a vertex in one set to a vertex in the other set. No edges exist within the same set.

Why each answer is right/wrong:

  • A. Triangle: ❌ A triangle is an odd cycle, which cannot be 2-colored. Not bipartite.
  • B. Square (4-cycle): ✓ This IS bipartite (sets: {1,3} and {2,4}), but answer C is more explicitly the definition
  • C. Two sets, every vertex in one set connected to all in other: ✅ This is the textbook definition of a bipartite graph (actually a complete bipartite graph)
  • D. Single strongly connected component: ❌ This describes directed graph connectivity, not bipartiteness
  • E. Pentagon (5-cycle): ❌ Odd cycle, cannot be 2-colored, not bipartite

Bipartite test: A graph is bipartite if and only if it contains no odd-length cycles.

Question 5: NFA Diagram (10 points)

Sample correct answer (3 states):
    0
  ┌───┐ 1    ┌───┐ 0,1   ┌───┐
→ │ S │────→ │ A │─────→ │ B │
  └───┘      └───┘       └─┬─┘
    ↓          ↑           │
    │ 0,1      │ 0,1       │
    └──────────┘           │
                           ← (accepting)

Legend:
  → : Start state
  ← or double circle: Accept state
                    

State descriptions:

  • S (Start): Haven't seen a '0' yet
    • On '0' → go to state A
    • On '1' → stay in S (keep waiting for first '0')
  • A (Seen '0', waiting for '1'): Have seen at least one '0'
    • On '0' → stay in A (can see more 0s)
    • On '1' → go to B (found the required '1'!)
  • B (Accept): Have seen both required '0' and '1' in correct order
    • On '0' or '1' → stay in B (accept any additional characters)

Grading criteria:

  • ✓ Start state clearly marked (2 pts)
  • ✓ Accept state(s) clearly marked - double circle or label (2 pts)
  • ✓ Transitions labeled with input symbols (2 pts)
  • ✓ Correctly accepts strings with 0...1 pattern (2 pts)
  • ✓ Arrows drawn (1 pt)
  • ✓ Reasonable diagram (1 pt)

Test cases:

  • "01" → ACCEPT ✓
  • "001" → ACCEPT ✓
  • "0111" → ACCEPT ✓
  • "00011" → ACCEPT ✓
  • "10" → REJECT ✓ (1 before 0)
  • "0" → REJECT ✓ (no 1 after)
  • "1" → REJECT ✓ (no 0)
  • "" (empty) → REJECT ✓

Questions 6-8: Complexity Classes (24 points)

Question 6: What is P?

ANSWER: Problem X can be solved in polynomial time.

Alternative acceptable answers (≤20 words):

  • "X has a deterministic polynomial-time algorithm"
  • "X can be solved efficiently"
  • "There exists algorithm solving X in O(n^k) for some k"
Question 7: What is NP?

ANSWER: Problem X can be verified in polynomial time.

Alternative acceptable answers (≤20 words):

  • "Solutions to X can be checked in polynomial time"
  • "X solvable in polynomial time via nondeterminism"
  • "Given a solution, can verify it's correct in polynomial time"
Question 8: Why P ⊆ NP?

ANSWER: If you can solve a problem in polynomial time, you can verify solutions in polynomial time.

Alternative acceptable answers (≤20 words):

  • "Solving is at least as hard as verifying"
  • "Any polynomial-time algorithm can also verify in polynomial time"
  • "If solvable fast, then verifiable fast"

Detailed reasoning: To verify a proposed solution, just solve the problem yourself and compare. Since solving takes polynomial time (because it's in P), verification also takes polynomial time, so it's in NP.

Question 9: NP-Complete Plain English (9 points)

Sample answers (≤20 words):
  • "Problems that are very hard to solve but easy to check if someone gives you an answer." (17 words) ✓
  • "The hardest problems where verifying solutions is quick but finding them is slow." (13 words) ✓
  • "Extremely difficult to solve, but you can quickly verify if a proposed solution is correct." (15 words) ✓
  • "Problems with no known fast solution, but solutions can be checked quickly." (12 words) ✓

Real-world analogies that would score well:

  • "Like a jigsaw puzzle - very hard to solve, but easy to check if complete." (14 words)
  • "Sudoku puzzles: difficult to solve, but verifying a filled grid is trivial." (11 words)

Grading deductions:

  • -3 pts: Uses technical jargon (polynomial, deterministic, Turing machine, etc.)
  • -6 pts: Uses heavy technical jargon throughout
  • 0 pts: More than 20 words

Question 10: Proving NP-Completeness (10 points)

Correct answers to check:
  • ✅ Show that problem X is in NP (or equivalently...)
  • ✅ Show that problem X can be verified in polynomial time
  • ✅ Reduce SAT (or another NP-complete problem) to problem X

Incorrect answers (do NOT check):

  • ❌ Show that problem X is not in NP-easy (this isn't a standard complexity class)
  • ❌ Show that problem X can be solved in polynomial time (this would put it in P, not prove NP-completeness!)
  • ❌ Show that problem X can only be solved in exponential time (we don't know this for NP-complete problems; it's the P≠NP question)
  • ❌ Show that problem X can only be verified in exponential time (contradicts being in NP)
  • ❌ Reduce problem X to SAT (direction is backwards)
  • ❌ Show that problem X is in P (contradicts NP-completeness unless P=NP)

Complete answer format (30 words max):

"Show X is in NP by demonstrating polynomial-time verification. Reduce a known NP-complete problem to X in polynomial time." (20 words)

The two key steps:

  1. X ∈ NP: Show solutions can be verified in polynomial time
  2. X is NP-hard: Show that some known NP-complete problem Y reduces to X (Y ≤p X)

Grading Summary

  • Question 1: 24 points (1 point per edge value)
  • Question 2: 33 points (3 points per path classification)
  • Question 3: 20 points (5 points per table row)
  • Question 4: 5 points (all or nothing)
  • Question 5: 10 points (NFA diagram graded on completeness and correctness)
  • Questions 6-8: 24 points (8 points each, must be ≤20 words)
  • Question 9: 9 points (plain English, ≤20 words, no jargon)
  • Question 10: 10 points (all correct boxes checked)

Total: 100 points