Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS 6515 Algorithms Test 3: NP-Completeness and Reductions, Exams of Nursing

A comprehensive overview of np-completeness and reductions, essential concepts in computer science. It includes definitions, examples, and explanations of key terms like independent set, clique, vertex cover, rudrata cycle, and rudrata path. The document also explores the concept of reduction, demonstrating how to reduce one problem to another, and provides examples of reductions between different problems. It is a valuable resource for students studying algorithms and complexity theory.

Typology: Exams

2024/2025

Available from 02/11/2025

smart-scores
smart-scores 🇺🇸

5

(2)

6.8K documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 6515 Algos Test 3 with verified answers
Search |!|Problem |!|- |!|correct |!|answer |!|A |!|search |!|problem |!|is |!|specified |!|by |!|an |!|algorithm |!|C |!|that |!|
takes |!|two |!|inputs, |!|an |!|instance |!|I |!|and |!|a |!|proposed |!|solution |!|S, |!|and |!|runs |!|in |!|time |!|polynomial |!|in
|!||I|. |!|We |!|say |!|S |!|is |!|a |!|solution |!|to |!|I |!|if |!|and |!|only |!|if |!|C(I, |!|S) |!|= |!|true
Steps |!|for |!|an |!|NP |!|Proof |!|- |!|correct |!|answer |!|1. |!|Demonstrate |!|that |!|problem |!|B |!|is |!|in |!|the |!|class |!|of
|!|NP |!|problems
2. |!|Demonstrate |!|that |!|problem |!|B |!|is |!|at |!|least |!|as |!|hard |!|as |!|a |!|problem |!|believed |!|to |!|be |!|NP-
Complete*. |!|
This |!|is |!|done |!|via |!|reduction |!|from |!|a |!|known |!|problem |!|A |!|(A→B)
2a. |!|Show |!|how |!|an |!|instance |!|of |!|A |!|is |!|converted |!|to |!|B |!|in |!|polynomial |!|time
2b. |!|Show |!|how |!|a |!|solution |!|to |!|B |!|can |!|be |!|converted |!|to |!|a |!|solution |!|for |!|A, |!|again |!|in |!|polynomial |!|
time
2c. |!|Show |!|that |!|a |!|solution |!|for |!|B |!|exists |!|if-and-only-if |!|(IFF) |!|a |!|solution |!|to |!|A |!|exists. |!|You |!|must |!|
prove |!|both |!|directions |!|parts:
|!|- |!|If |!|you |!|have |!|a |!|solution |!|to |!|B |!|you |!|have |!|a |!|solution |!|to |!|A
If |!|there |!|is |!|no |!|solution |!|for |!|B, |!|then |!|no |!|solution |!|exists |!|for |!|A. |!|This |!|may |!|be |!|done |!|via |!|the |!|
contra-positive |!|approach, |!|showing |!|that |!|if |!|a |!|solution |!|exists |!|for |!|A |!|then |!|a |!|solution |!|for |!|B |!|must
|!|exist
Reduction |!|- |!|correct |!|answer |!|A |!|reduction |!|from |!|search |!|problem |!|A |!|to |!|search |!|problem |!|B |!|is |!|a |!|
polynomial-time |!|algorithm |!|f |!|that |!|transforms |!|any |!|instance |!|I |!|of |!|A |!|into |!|an |!|instance |!|f(I) |!|of |!|B, |!|
together |!|with |!|another |!|polynomial-time |!|algorithm |!|h |!|that |!|maps |!|any |!|solution |!|S |!|of |!|f(I) |!|back |!|
into |!|a |!|solution |!|h(S) |!|of |!|I; |!|see |!|the |!|following |!|diagram. |!|If |!|f(I) |!|has |!|no |!|solution, |!|then |!|neither |!|
does |!|I
Independent |!|Set |!|Definition |!|- |!|correct |!|answer |!|Given |!|a |!|graph |!|G |!|= |!|(V, |!|E) |!|and |!|an |!|integer |!|k, |!|is
|!|there |!|a |!|subset
of |!|vertices |!|S |!| |!|V |!|such |!|that |!|| |!|S |!|| |!| |!|k, |!|and |!|for |!|each |!|edge |!|at |!|most |!|one |!|of |!|its |!|endpoints |!|is
|!|in |!|S |!|?
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download CS 6515 Algorithms Test 3: NP-Completeness and Reductions and more Exams Nursing in PDF only on Docsity!

CS 6515 Algos Test 3 with verified answers

Search |!|Problem |!|- |!|correct |!|answer |!| A |!|search |!|problem |!|is |!|specified |!|by |!|an |!|algorithm |!|C |!|that |!| takes |!|two |!|inputs, |!|an |!|instance |!|I |!|and |!|a |!|proposed |!|solution |!|S, |!|and |!|runs |!|in |!|time |!|polynomial |!|in |!||I|. |!|We |!|say |!|S |!|is |!|a |!|solution |!|to |!|I |!|if |!|and |!|only |!|if |!|C(I, |!|S) |!|= |!|true Steps |!|for |!|an |!|NP |!|Proof |!|- |!|correct |!|answer |!| 1. |!|Demonstrate |!|that |!|problem |!|B |!|is |!|in |!|the |!|class |!|of |!|NP |!|problems

  1. |!|Demonstrate |!|that |!|problem |!|B |!|is |!|at |!|least |!|as |!|hard |!|as |!|a |!|problem |!|believed |!|to |!|be |!|NP- Complete*. |!| This |!|is |!|done |!|via |!|reduction |!|from |!|a |!|known |!|problem |!|A |!|(A→B) 2a. |!|Show |!|how |!|an |!|instance |!|of |!|A |!|is |!|converted |!|to |!|B |!|in |!|polynomial |!|time 2b. |!|Show |!|how |!|a |!|solution |!|to |!|B |!|can |!|be |!|converted |!|to |!|a |!|solution |!|for |!|A, |!|again |!|in |!|polynomial |!| time 2c. |!|Show |!|that |!|a |!|solution |!|for |!|B |!|exists |!|if-and-only-if |!|(IFF) |!|a |!|solution |!|to |!|A |!|exists. |!|You |!|must |!| prove |!|both |!|directions |!|parts: |!|- |!|If |!|you |!|have |!|a |!|solution |!|to |!|B |!|you |!|have |!|a |!|solution |!|to |!|A If |!|there |!|is |!|no |!|solution |!|for |!|B, |!|then |!|no |!|solution |!|exists |!|for |!|A. |!|This |!|may |!|be |!|done |!|via |!|the |!| contra-positive |!|approach, |!|showing |!|that |!|if |!|a |!|solution |!|exists |!|for |!|A |!|then |!|a |!|solution |!|for |!|B |!|must |!|exist Reduction |!|- |!|correct |!|answer |!| A |!|reduction |!|from |!|search |!|problem |!|A |!|to |!|search |!|problem |!|B |!|is |!|a |!| polynomial-time |!|algorithm |!|f |!|that |!|transforms |!|any |!|instance |!|I |!|of |!|A |!|into |!|an |!|instance |!|f(I) |!|of |!|B, |!| together |!|with |!|another |!|polynomial-time |!|algorithm |!|h |!|that |!|maps |!|any |!|solution |!|S |!|of |!|f(I) |!|back |!| into |!|a |!|solution |!|h(S) |!|of |!|I; |!|see |!|the |!|following |!|diagram. |!|If |!|f(I) |!|has |!|no |!|solution, |!|then |!|neither |!| does |!|I Independent |!|Set |!|Definition |!|- |!|correct |!|answer |!| Given |!|a |!|graph |!|G |!|= |!|(V, |!|E) |!|and |!|an |!|integer |!|k, |!|is |!|there |!|a |!|subset of |!|vertices |!|S |!|⊆ |!|V |!|such |!|that |!|| |!|S |!|| |!|≥ |!|k, |!|and |!|for |!|each |!|edge |!|at |!|most |!|one |!|of |!|its |!|endpoints |!|is |!|in |!|S |!|?

Independent |!|Set |!|Input/Output |!|- |!|correct |!|answer |!| Input: |!|An |!|undirected |!|graph, |!|G |!|= |!|(V, |!|E). |!|A |!| goal |!|g. Output: |!|The |!|independent |!|set |!|S |!|with |!|size |!||S| |!|≥ |!|g, |!|if |!|one |!|exists. Clique |!|definition |!|- |!|correct |!|answer |!| find |!|a |!|set |!|of |!|g |!|ver- |!|tices |!|such |!|that |!|all |!|possible |!|edges |!| between |!|them |!|are |!|present Clique |!|Input |!|/ |!|Output |!|- |!|correct |!|answer |!| Input: |!|A |!|graph |!|G |!|= |!|(V, |!|E) |!|and |!|a |!|goal, |!|g. Output: |!|A |!|subset |!|of |!|vertices, |!|S |!|⊆ |!|V |!|where |!|S |!|is |!|a |!|clique |!|whose |!|size |!|meets |!|the |!|goal, |!|so |!||S| |!|≥ |!|g. Vertex |!|Cover |!|definition |!|- |!|correct |!|answer |!| find |!|b |!|vertices |!|that |!|cover |!|(touch) |!|every |!|edge. |!| This |!|is |!|a |!|special |!|case |!|of |!|set |!|cover Vertex |!|Cover |!|Input/Output |!|- |!|correct |!|answer |!| Input: |!|A |!|graph, |!|G |!|= |!|(V, |!|E) |!|and |!|a |!|budget, |!|b Output: |!|A |!|set |!|of |!|vertices |!|S |!|⊂ |!|V |!|that |!|form |!|a |!|vertex |!|cover |!|with |!|a |!|size |!|that |!|is |!|under-budget, |!|so |!||S| |!|≤ |!|b. Rudrata |!|Cycle |!|Definition |!|- |!|correct |!|answer |!| given |!|a |!|graph, |!|find |!|a |!|cycle |!|that |!|visits |!|each |!| vertex |!|exactly |!|once—or |!|report |!|that |!|no |!|such |!|cycle |!|exists Rudrata |!|Cycle |!|Input/Output |!|- |!|correct |!|answer |!| Input: |!|Graph |!|G |!|= |!|(V, |!|E)Output: |!|A |!|cycle |!|that |!| goes |!|through |!|every |!|vertex |!|of |!|the |!|graph |!|exactly |!|once Rudrata |!|Path |!|Definition |!|- |!|correct |!|answer |!| given |!|a |!|graph, |!|find |!|a |!|path |!|that |!|visits |!|each |!|vertex |!|exactly |!|once—or |!|report |!|that |!|no |!|such |!|path |!|exists Rudrata |!|(s, |!|t)-Path |!|Input/Output |!|- |!|correct |!|answer |!| Input: |!|Graph |!|G |!|= |!|(V, |!|E), |!|Start |!|and |!|End |!| Vertices |!|(s, |!|t) Output: |!|A |!|path |!|that |!|starts |!|at |!|s, |!|ends |!|at |!|t, |!|and |!|goes |!|through |!|every |!|vertex |!|of |!|the |!|graph |!| exactly |!|once

Primal |!|Linear |!|Program |!|- |!|correct |!|answer |!| max |!|cTx |!| Ax |!|≤ |!|b |!| x≥ Dual |!|Linear |!|Program |!|- |!|correct |!|answer |!| min |!|yTb |!| yT |!|A |!|≥ |!|cT |!| y≥ Duality |!|Theorem |!|- |!|correct |!|answer |!| If |!|a |!|linear |!|program |!|has |!|a |!|bounded |!|optimum, |!|then |!|so |!| does |!|its |!|dual, |!|and |!|the |!|two |!|optimum |!|values |!|coincide Balanced |!|Cut |!|Definition |!|- |!|correct |!|answer |!| given |!|a |!|graph |!|with |!|n |!|vertices |!|and |!|a |!|budget |!|b, |!| partition |!|the |!|vertices |!|into |!|two |!|sets |!|S |!|and |!|T |!|such |!|that |!||S|,|T| |!|≥ |!|n/3 |!|and |!|such |!|that |!|there |!| are |!|at |!|most |!|b |!|edges |!|between |!|S |!|and |!|T 3D |!|Matching |!|Definition |!|- |!|correct |!|answer |!| there |!|are |!|n |!|boys |!|and |!|n |!|girls, |!|but |!|also |!|n |!|pets, |!| and |!|the |!|compatibilities |!|among |!|them |!|are |!|specified |!|by |!|a |!|set |!|of |!|triples, |!|each |!|containing |!|a |!|boy, |!|a |!|girl,andapet. |!|Intuitively,a |!|triple(b,g,p) |!|means |!|that |!|boy |!|b,girl |!|g,and |!|pet |!|p |!|get |!|along |!|well |!| together. |!|We |!|want |!|to |!|find |!|n |!|disjoint |!|triples |!|and |!|thereby |!|create |!|n |!|harmonious |!|households Set |!|Cover |!|Definition |!|- |!|correct |!|answer |!| we |!|are |!|given |!|a |!|set |!|E |!|and |!|several |!|subsets |!|of |!|it, |!|S1, |!|. |!|. |!|. |!|, |!|Sm, |!|along |!|with |!|a |!|budget |!|b. |!|We |!|are |!|asked |!|to |!|select |!|b |!|of |!|these |!|subsets |!|so |!|that |!| their |!|union |!|is |!|E RUDRATA |!|(s,t)-PATH−→RUDRATA |!|CYCLE |!|Reduction |!|- |!|correct |!|answer |!| 1. |!|The |!|reduction |!|maps |!| an |!|instance |!|(G |!|= |!|(V, |!|E), |!|s, |!|t) |!|of |!|RUDRATA |!|(s, |!|t)-PATH |!|into |!|an |!|instance |!|G |!|= |!|(V |!| , |!|E ) |!|of |!| RUDRATA |!|CYCLE |!|as |!|follows: |!|G |!|is |!|simply |!|G |!|with |!|an |!|additional |!|vertex |!|x |!|and |!|two |!|new |!|edges |!|{s, |!|x} |!|and |!|{x, |!|t}

  1. |!|How |!|do |!|we |!|recover |!|a |!|Rudrata(s,t)-pathinG |!|given |!|any |!|Rudrata |!|cycle |!|in |!|G? |!|Easy, |!|we |!|just |!| delete |!|the |!|edges |!|{s, |!|x} |!|and |!|{x, |!|t} |!|from |!|the |!|cycle
  2. |!|When |!|the |!|instance |!|of |!|RUDRATA |!|CYCLE |!|has |!|a |!|solution.

Since |!|the |!|new |!|vertex |!|x |!|has |!|only |!|two |!|neighbors, |!|s |!|and |!|t, |!|any |!|Rudrata |!|cycle |!|in |!|G |!|must |!| consec- |!|utively |!|traverse |!|the |!|edges |!|{t, |!|x} |!|and |!|{x, |!|s}. |!|The |!|rest |!|of |!|the |!|cycle |!|then |!|traverses |!| every |!|other |!|vertex |!|en |!|route |!|from |!|s |!|to |!|t. |!|Thus |!|deleting |!|the |!|two |!|edges |!|{t, |!|x} |!|and |!|{x, |!|s} |!| from |!|the |!|Rudrata |!|cycle |!|gives |!|a |!|Rudrata |!|path |!|from |!|s |!|to |!|t |!|in |!|the |!|original |!|graph |!|G.

  1. |!|When |!|the |!|instance |!|of |!|RUDRATA |!|CYCLE |!|does |!|not |!|have |!|a |!|solution. In |!|this |!|case |!|we |!|must |!|show |!|that |!|the |!|original |!|instance |!|of |!|RUDRATA |!|(s,t)-PATH |!|cannot |!|have |!|a |!|solution |!|either. |!|It |!|is |!|usually |!|easier |!|to |!|prove |!|the |!|contrapositive, |!|that |!|is, |!|to |!|show |!|that |!|if |!| there |!|is |!|a |!|Rudrata |!|(s, |!|t)-path |!|in |!|G, |!|then |!|there |!|is |!|also |!|a |!|Rudrata |!|cycle |!|in |!|G. |!|But |!|this |!|is |!| easy: |!|just |!|add |!|the |!|two |!|edges |!|{t, |!|x} |!|and |!|{x, |!|s} |!|to |!|the |!|Rudrata |!|path |!|to |!|close |!|the |!|cycle. One |!|last |!|detail, |!|crucial |!|but |!|typically |!|easy |!|to |!|check, |!|is |!|that |!|the |!|pre- |!|and |!|postprocessing |!| functions |!|take |!|time |!|polynomial |!|in |!|the |!|size |!|of |!|the |!|instance |!|(G, |!|s, |!|t). 3SAT−→INDEPENDENT |!|SET |!|Reduction |!|- |!|correct |!|answer |!| Given |!|an |!|instance |!|I |!|of |!|3SAT, |!|we |!| create |!|an |!|instance |!|(G, |!|g) |!|of |!|INDEPENDENT |!|SET |!|as |!|follows.
  • |!|Graph |!|G |!|has |!|a |!|triangle |!|for |!|each |!|clause |!|(or |!|just |!|an |!|edge, |!|if |!|the |!|clause |!|has |!|two |!|literals), |!| with |!|vertices |!|labeled |!|by |!|the |!|clause's |!|literals, |!|and |!|has |!|additional |!|edges |!|between |!|any |!|two |!| vertices |!|that |!|represent |!|opposite |!|literals.
  • |!|The |!|goal |!|g |!|is |!|set |!|to |!|the |!|number |!|of |!|clauses.
  1. |!|Given |!|an |!|independent |!|set |!|S |!|of |!|g |!|vertices |!|in |!|G, |!|it |!|is |!|possible |!|to |!|efficiently |!|recover |!|a |!| satis- |!|fying |!|truth |!|assignment |!|to |!|I. For |!|any |!|variable |!|x, |!|the |!|set |!|S |!|cannot |!|contain |!|vertices |!|labeled |!|both |!|x |!|and |!|x, |!|because |!|any |!| such |!|pair |!|of |!|vertices |!|is |!|connected |!|by |!|an |!|edge. |!|So |!|assign |!|x |!|a |!|value |!|of |!|true |!|if |!|S |!|contains |!|a |!| vertex |!|labeled |!|x, |!|and |!|a |!|value |!|of |!|false |!|if |!|S |!|contains |!|a |!|vertex |!|labeled |!|x |!|(if |!|S |!|contains |!| neither, |!|then |!|assign |!|either |!|value |!|to |!|x). |!|Since |!|S |!|has |!|g |!|vertices, |!|it |!|must |!|have |!|one |!|vertex |!|per |!|clause; |!|this |!|truth |!|assignment |!|satisfies |!|those |!|particular |!|literals, |!|and |!|thus |!|satisfies |!|all |!|clauses.
  2. |!|If |!|graph |!|G |!|has |!|no |!|independent |!|set |!|of |!|size |!|g, |!|then |!|the |!|Boolean |!|formula |!|I |!|is |!|unsatisfiable. It |!|is |!|usually |!|cleaner |!|to |!|prove |!|the |!|contrapositive, |!|that |!|if |!|I |!|has |!|a |!|satisfying |!|assignment |!|then |!| G |!|has |!|an |!|independent |!|set |!|of |!|size |!|g. |!|This |!|is |!|easy: |!|for |!|each |!|clause, |!|pick |!|any |!|literal |!|whose |!| value |!|under |!|the |!|satisfying |!|assignment |!|is |!|true |!|(there |!|must |!|be |!|at |!|least |!|one |!|such |!|literal), |!|and |!| add |!|the |!|corresponding |!|vertex |!|to |!|S.

assume |!|that |!|no |!|literal |!|appears |!|more |!|than |!|twice, |!|and |!|so |!|each |!|variable |!|gadget |!|has |!|enough |!| pets, |!|two |!|for |!|negated |!|occurrences |!|and |!|two |!|for |!|unnegated. The |!|reduction |!|now |!|seems |!|complete: |!|from |!|any |!|matching |!|we |!|can |!|recover |!|a |!|satisfying |!|truth |!| assignment |!|by |!|simply |!|looking |!|at |!|each |!|variable |!|gadget |!|and |!|seeing |!|with |!|which |!|girl |!|bx0 |!|was |!| matched. |!|And |!|from |!|any |!|satisfying |!|truth |!|assignment |!|we |!|can |!|match |!|the |!|gadget |!|corresponding |!| to |!|each |!|variable |!|x |!|so |!|that |!|triples |!|(bx0, |!|gx1, |!|px0) |!|and |!|(bx1, |!|gx0, |!|px2) |!|are |!|chosen |!|if |!|x |!|= |!| true |!|and |!|triples |!|(bx0, |!|gx0, |!|px1) |!|and |!|(bx1, |!|gx1, |!|px3) |!|are |!|chosen |!|if |!|x |!|= |!|false; |!|and |!|for |!|each |!| clause |!|c |!|match |!|bc |!|and |!|gc |!|with |!|the |!|pet |!|that |!|corresponds |!|to |!|one |!|of |!|its |!|satisfying |!|literals. 3D |!|MATCHING−→ZOE |!|(Zero |!|to |!|One |!|Equations) |!|- |!|correct |!|answer |!| Recall |!|that |!|in |!|ZOE |!|we |!|are |!|given |!|an |!|m×n |!|matrix |!|A |!|with |!| 0 − 1 |!|entries, |!|and |!|we |!|must |!|find |!|a |!| 0 − 1 vector |!|x |!|= |!|(x1, |!|. |!|. |!|. |!|, |!|xn) |!|such |!|that |!|the |!|m |!|equations |!|Ax |!|= |!| 1 are |!|satisfied, |!|where |!|by |!| 1 |!|we |!|denote |!|the |!|column |!|vector |!|of |!|all |!|1's. |!| 3D |!|MATCHING |!|(m |!|boys, |!|m |!|girls, |!|m |!|pets, |!|and |!|n |!|boy-girl-pet |!|triples) |!|in |!|the |!|language |!|of |!|ZOE. |!|We |!|have |!| 0 |!|− |!| 1 |!|variables |!|x1, |!|. |!|. |!|. |!|, |!|xn, |!|one |!|per |!|triple, |!|where |!|xi |!|= |!| 1 |!|means |!|that |!|the |!|ith |!| triple |!|is |!|chosen |!|for |!|the |!|matching, |!|and |!|xi |!|= |!| 0 |!|means |!|that |!|it |!|is |!|not |!|chosen. Now |!|all |!|we |!|have |!|to |!|do |!|is |!|write |!|equations |!|stating |!|that |!|the |!|solution |!|described |!|by |!|the |!|xi's |!|is |!|a |!|legitimate |!|matching. |!|For |!|each |!|boy |!|(or |!|girl, |!|or |!|pet), |!|suppose |!|that |!|the |!|triples |!|containing |!| him |!|(or |!|her, |!|or |!|it) |!|are |!|those |!|numbered |!|j1, |!|j2, |!|. |!|. |!|. |!|, |!|jk; |!|the |!|appropriate |!|equation |!|is |!|then xj1 |!|+xj2 |!|+···+xjk |!|=1, which |!|states |!|that |!|exactly |!|one |!|of |!|these |!|triples |!|must |!|be |!|included |!|in |!|the |!|matching. ZOE−→SUBSET |!|SUM |!|Reduction |!|- |!|correct |!|answer |!| This |!|is |!|a |!|reduction |!|between |!|two |!|special |!| cases |!|of |!|ILP: |!|one |!|with |!|many |!|equations |!|but |!|only |!| 0 |!|− |!| 1 |!|coefficients, |!|and |!|the |!|other |!|with |!|a |!| single |!|equation |!|but |!|arbitrary |!|integer |!|coefficients. But |!|if |!|we |!|think |!|of |!|the |!|columns |!|as |!|binary |!|integers |!|(read |!|from |!|top |!|to |!|bottom), |!|we |!|are |!| looking |!|for |!|a |!|subset |!|of |!|the |!|integers |!|18, |!|5, |!|4, |!| 8 |!|that |!|add |!|up |!|to |!|the |!|binary |!|integer |!| 111112 |!| = |!|31. ZOE−→ILP |!|- |!|correct |!|answer |!| In |!|ILP |!|we |!|are |!|looking |!|for |!|an |!|integer |!|vector |!|x |!|that |!|satisfies |!|Ax |!|≤ |!|b, |!|for |!|given |!|matrix |!|A |!|and |!|vector |!|b. |!|To |!|write |!|an |!|instance |!|of |!|ZOE |!|in |!|this |!|precise |!|form, |!| we |!|need |!|to |!|rewrite |!|each |!|equation |!|of |!|the |!|ZOE |!|instance |!|as |!|two |!|inequalities |!|(recall |!|the |!| transformations |!|of |!|Section |!|7.1.4), |!|and |!|to |!|add |!|for |!|each |!|variable |!|xi |!|the |!|inequalities |!|xi |!|≤ |!| 1 |!| and |!|−xi |!|≤ |!|0.

ZOE−→RUDRATA |!|CYCLE |!|Reduction |!|- |!|correct |!|answer |!| RUDRATA |!|CYCLE |!|problem |!|we |!|seek |!|a |!| cycle |!|in |!|a |!|graph |!|that |!|visits |!|every |!|vertex |!|exactly |!|once. |!|We |!|shall |!|prove |!|it |!|NP-complete |!|in |!| two |!|stages: |!|first |!|we |!|will |!|reduce |!|ZOE |!|to |!|a |!|generalization |!|of |!|RUDRATA |!|CYCLE, |!|called |!| RUDRATA |!|CYCLE |!|WITH |!|PAIRED |!|EDGES, |!|and |!|then |!|we |!|shall |!|see |!|how |!|to |!|get |!|rid |!|of |!|the |!|extra |!| features |!|of |!|that |!|problem |!|and |!|reduce |!|it |!|to |!|the |!|plain |!|RUDRATA |!|CYCLE |!|problem. RUDRATA |!|CYCLE−→TSP |!|Reduction |!|- |!|correct |!|answer |!| Given |!|a |!|graph |!|G |!|= |!|(V, |!|E), |!|construct |!|the |!|following |!|instance |!|of |!|the |!|TSP: |!|the |!|set |!|of |!|cities |!|is |!|the |!|same |!|as |!|V |!|, |!|and |!|the |!|distance |!| between |!|cities |!|u |!|and |!|v |!|is |!| 1 |!|if |!|{u, |!|v} |!|is |!|an |!|edge |!|of |!|G |!|and |!| 1 |!|+ |!|α |!|otherwise, |!|for |!|some |!|α |!|> |!| 1 |!|to |!|be |!|determined. |!|The |!|budget |!|of |!|the |!|TSP |!|instance |!|is |!|equal |!|to |!|the |!|number |!|of |!|nodes, |!||V |!||. It |!|is |!|easy |!|to |!|see |!|that |!|if |!|G |!|has |!|a |!|Rudrata |!|cycle, |!|then |!|the |!|same |!|cycle |!|is |!|also |!|a |!|tour |!|within |!| the |!|budget |!|of |!|the |!|TSP |!|instance; |!|and |!|that |!|conversely, |!|if |!|G |!|has |!|no |!|Rudrata |!|cycle, |!|then |!|there |!|is |!|no |!|solution: |!|the |!|cheapest |!|possible |!|TSP |!|tour |!|has |!|cost |!|at |!|least |!|n |!|+ |!|α |!|(it |!|must |!|use |!|at |!| least |!|one |!|edge |!|of |!|length |!| 1 |!|+ |!|α, |!|and |!|the |!|total |!|length |!|of |!|all |!|n |!|− |!| 1 |!|others |!|is |!|at |!|least |!|n |!|− |!| 1). |!|Thus |!|RUDRATA |!|CYCLE |!|reduces |!|to |!|TSP. ZERO-ONE |!|EQUATIONS |!|(ZOE) |!|Input/Output |!|- |!|correct |!|answer |!| Input: |!|a |!|𝑚×𝑛m×n |!|matrix |!|𝐴A, |!| all |!|of |!|whose |!|entries |!|are |!| 0 |!|or |!| 1 Goal: |!|Find |!|a |!|𝑛n-vector |!|𝑥x, |!|all |!|of |!|whose |!|entries |!|are |!| 0 |!|or |!|1, |!|such |!|that |!|𝐴𝑥=1Ax=1, |!|where |!| 11 |!|denotes |!|the |!|all-ones |!|vector Dense |!|subgraph |!|generalization |!|- |!|correct |!|answer |!| where |!|you |!|want |!|to |!|find |!|a |!|vertices |!|in |!|a |!| graph |!|that |!|contain |!|b |!|edges |!|(generalization |!|of |!|independent |!|set |!|where |!|you |!|want |!|to |!|find |!| vertices |!|that |!|contain |!|no |!|edges |!|between |!|them). Vertex |!|Cover |!|Reduction |!|-> |!|Hitting |!|Set |!|- |!|correct |!|answer |!| eduction |!|from |!|VC |!|by |!|making |!|each |!| edge |!|a |!|set, |!|so |!|the |!|hitting |!|set |!|always |!|contains |!|one |!|vertex |!|from |!|each |!|edge Vertex |!|Cover |!|Reduction |!|-> |!|Dominating |!|Set |!|- |!|correct |!|answer |!| reduction |!|from |!|VC |!|by |!|forcing |!| all |!|edges |!|to |!|have |!|a |!|vertex |!|in |!|D |!|through |!|a |!|triangle |!|formation 3 |!|coloring |!|-> |!|k-coloring |!|- |!|correct |!|answer |!| 3-Coloring |!|problem |!|can |!|be |!|proved |!|NP-Complete |!| making |!|use |!|of |!|the |!|reduction |!|from |!|3SAT |!|Graph |!|Coloring |!|(from |!|3SAT). |!|

Solution: |!|This |!|is |!|a |!|generalization |!|of |!|SAT: |!|simply |!|let |!|k |!|= |!|n |!|to |!|allow |!|every |!|variable |!|to |!|be |!|set |!|to |!|true |!|if |!|necessary. Longer |!|solution: |!|First, |!|we |!|show |!|that |!|Stingy |!|SAT |!|is |!|in |!|NP. |!|Let |!|the |!|input |!|formula |!|be |!|denoted |!|by |!|f, |!|and |!|let |!|n |!|be |!|the |!|number |!|of |!|variables |!|and |!|m |!|be |!|the |!|number |!|of |!|clauses. |!|Given |!|a |!| satisfying |!|assignment |!|σ |!|of |!|F, |!|we |!|can |!|just |!|check |!|clause |!|by |!|clause |!|that |!|σ |!|satisfies |!|every |!|one; |!|this |!|takes |!|O(n) |!|time |!|per |!|clause |!|and |!|thus |!|O(nm) |!|total |!|time. |!|Then |!|in |!|O(n) |!|time, |!|we |!|count |!| how |!|many |!|variables |!|are |!|set |!|to |!|be |!|TRUE |!|in |!|σ |!|and |!|check |!|that |!|the |!|number |!|is |!|larger |!|than |!|k |!| or |!|not. Now, |!|we |!|show: |!|SAT |!|→ |!|Stingy |!|SAT. |!|Suppose |!|you |!|have |!|an |!|input |!|formula |!|f |!|for |!|SAT |!|with |!|n |!| variables |!|and |!|m |!|clauses. |!|Now, |!|run |!|Stingy |!|SAT |!|on |!|f |!|with |!|k |!|= |!|n. |!|Clearly, |!|every |!|assignment |!| over |!|n |!|variables |!|will |!|have |!|at |!|most |!|n |!|variables |!|set |!|to |!|true, |!|so |!|this |!|extra |!|restriction |!|will |!|not |!|constrain |!|the |!|set |!|of |!|solutions. |!|Then, |!|if |!|Stingy |!|SAT |!|returns |!|a |!|satisfying |!|assignment, |!|that |!| assignment |!|will |!|also |!|satisfy |!|the |!|original |!|SAT |!|problem. |!|Likewise, |!|if |!|Stingy |!|SAT |!|returns |!|that |!| there |!|is |!|no |!|such |!|assignment, |!|then |!|there |!|can |!|be |!|no |!|solution |!|to |!|the |!|SAT |!|problem. |!|This |!| completes |!|the |!|reduction, |!|which |!|is |!|clearly |!|polynomial |!|time |!|(the |!|only |!|change |!|was |!|setting |!|k |!|= |!| n). |!|Then, |!|since |!|SAT |!|is |!|NP-complete, |!|Stingy |!|SAT |!|must |!|also |!|be |!|NP-complete. Clique-3 |!|(8.4) |!|- |!|correct |!|answer |!| Given |!|an |!|input |!|graph |!|G |!|= |!|(V, |!|E), |!|a |!|goal |!|g, |!|and |!|a |!|potential |!|solution |!|set |!|S |!|⊆ |!|V |!|, |!|it |!|is |!|easy |!|to |!|verify |!|whether |!|S |!|is |!|a |!|clique |!|by |!|checking |!|that |!|all |!|pairs |!| of |!|vertices |!|in |!|S |!|are |!|connected |!|in |!|O(n2) |!|time, |!|and |!|to |!|check |!|that |!||S| |!|≥ |!|g |!|in |!|O(n) |!|time. |!| Since |!|a |!|solution |!|can |!|be |!|verified |!|in |!|polynomial |!|time, |!|clique-3 |!|is |!|in |!|NP. 3D |!|Matching |!|-> |!|SAT |!|(8.5) |!|- |!|correct |!|answer |!| We |!|are |!|given |!|a |!|set |!|of |!|n |!|"edges" |!|which |!|each |!| contain |!|three |!|items. |!|A |!|valid |!|matching |!|exists |!|if |!|we |!|can |!|choose |!|a |!|set |!|of |!|edges |!|such |!|that |!| every |!|item |!|appears |!|in |!|an |!|edge, |!|but |!|no |!|item |!|appears |!|in |!|more |!|than |!|one |!|edge. |!|Define |!| variables |!|{e1, |!|e2, |!|. |!|. |!|. |!|, |!|en} |!|where |!|true |!|indicates |!|that |!|an |!|edge |!|is |!|chosen. |!|For |!|every |!|item |!| (of |!|any |!|type), |!|let |!|a |!|be |!|a |!|k-vector |!|of |!|indices |!|of |!|edges |!|in |!|which |!|the |!|item |!|appears; |!|e.g., |!|if |!| the |!|item |!|appears |!|in |!|e1, |!|e3, |!|and |!|e7, |!|then |!|a |!|= |!|[1, |!|3, |!|7] |!|(and |!|k |!|= |!|3). |!|Create |!|clauses |!|as |!| follows: |!|• |!|Add |!|clause |!|(ea1 |!|∨ |!|ea2 |!|∨ |!|. |!|. |!|. |!|eak |!|). |!|This |!|clause |!|ensures |!|that |!|the |!|item |!|appears |!|at |!|least |!|once. |!|• |!|For |!|every |!|pair |!|i, |!|j |!|∈ |!|{1..k}, |!|add |!|clause |!|(¯eai |!|∨ |!|e¯aj |!|). |!|Taken |!|together |!| these |!|clauses |!|ensure |!|that |!|the |!|item |!|cannot |!|appear |!|more |!|than |!|once. |!|We |!|must |!|show |!|that |!|this |!|reduction |!|takes |!|polynomial |!|time. |!|If |!|there |!|are |!|m |!|items |!|and |!|n |!|edges, |!|then |!|we |!|must |!|iterate |!| over |!|m |!|items, |!|generating |!|for |!|each |!|item |!|one |!|clause |!|with |!|at |!|most |!|n |!|entries |!|and |!|at |!|most |!| n(n−1) |!|clauses |!|with |!| 2 |!|entries. |!|Thus |!|the |!|overall |!|reduction |!|is |!|O(mn2 |!|). Rudrata |!|cycle |!|-> |!|SAT |!|(8.5) |!|- |!|correct |!|answer |!| Following |!|the |!|hint |!|given |!|in |!|the |!|book, |!|we |!| define |!|variables |!|xij |!|to |!|mean |!|that |!|vertex |!|i |!|is |!|the |!|j |!|th |!|vertex |!|in |!|the |!|Rudrata |!|cycle. |!|We |!| require |!|that |!|each |!|vertex |!|appears |!|once |!|and |!|only |!|once |!|in |!|the |!|cycle, |!|and |!|that |!|neighbors |!|in |!|

the |!|cycle |!|are |!|connected |!|by |!|an |!|edge. |!|For |!|the |!|first |!|requirement, |!|we |!|first |!|add |!|a |!|clause |!|(xi1 |!|∨ |!|xi2 |!|∨ |!|· |!|· |!|· |!|∨ |!|xin) |!|for |!|each |!|vertex |!|i. |!|Next, |!|for |!|each |!|cycle |!|entry |!|j, |!|we |!|add |!|clauses |!|for |!|each |!|pair |!|i, |!|k |!|of |!|vertices |!|ensuring |!|that |!|no |!|more |!|than |!|one |!|vertex |!|can |!|be |!|assigned |!|to |!|the |!|entry: |!|(¯xij |!|∨ |!|x¯kj |!|). |!|For |!|the |!|second |!|requirement, |!|if |!|there |!|is |!|no |!|edge |!|between |!|some |!|vertex |!|i |!|and |!|k |!|we |!|want |!|to |!|express |!|the |!|statement |!|(xij |!|∧ |!|xk,j+1) |!|for |!|every |!|cycle |!|location |!|j. |!|Therefore, |!| for |!|each |!|pair |!|of |!|items |!|i, |!|k |!|such |!|that |!|there |!|is |!|no |!|edge |!|between |!|i |!|and |!|k, |!|for |!|and |!|every |!| cycle |!|entry |!|j, |!|add |!|clause |!|(¯xij |!|∨ |!|x¯k,j+1), |!|letting |!|j |!|+ |!| 1 |!|= |!| 1 |!|when |!|j |!|= |!|n. |!|We |!|assert |!|that |!|this |!|reduction |!|is |!|correct |!|by |!|construction. |!|Construction |!|of |!|the |!|sat |!|instance |!|involves |!|the |!|creation |!| of |!|n |!|clauses |!|with |!|n |!|entries |!|each |!|plus |!|n |!| 3 |!|clauses |!|with |!| 2 |!|entries |!|each |!|for |!|the |!|first |!| requirement. |!|The |!|second |!|requirement |!|adds |!|at |!|most |!|another |!|n |!| 3 |!|clauses |!|with |!| 2 |!|entries |!| each. |!|Therefore |!|the |!|reduction |!|takes |!|O(n |!| 3 |!|) |!|time. 3SAT |!|with |!|each |!|literal |!|appearing |!|once |!|(8.6) |!|- |!|correct |!|answer |!| Use |!|a |!|bipartite |!|graph, |!|set |!|up |!|as |!|a |!|max |!|flow |!|problem |!|with |!|a |!|master |!|source |!|and |!|sink. |!|This |!|can |!|be |!|solved |!|in |!|poly |!|time. IS |!|with |!|degree |!|<=4 |!|(8.6) |!|- |!|correct |!|answer |!| 3SAT |!|-> |!|IS. |!|The |!|conclusion |!|was |!|that |!|an |!|IS |!|in |!| this |!|graph |!|provides |!|a |!|satisfying |!|assignment |!|for |!|3SAT, |!|but |!|obviously |!|in |!|the |!|constructed |!|graph |!|each |!|vertex |!|only |!|has |!|a |!|degree |!|of |!|(at |!|most) |!|4! 3SAT |!|with |!| 3 |!|literals |!|(8.7) |!|- |!|correct |!|answer |!| Create |!|a |!|bipartite |!|graph |!|with |!|clauses |!|on |!|the |!| left, |!|variables |!|on |!|the |!|right, |!|and |!|edges |!|whenever |!|a |!|variable |!|appears |!|in |!|a |!|clause. |!|Create |!|a |!| master |!|source |!|and |!|sink. |!|Then |!|its |!|a |!|max |!|flow |!|problem |!|and |!|solvable |!|in |!|poly |!|time Exact |!|4SAT |!|(8.8) |!|- |!|correct |!|answer |!| ->3SAT. |!| Check |!|clause |!|satisfaction |!|in |!|O(m) |!|time |!| Directly |!|assign |!|clauses |!|with |!|one |!|variable. |!|For |!|two/three |!|variables |!|use |!|auxiliary |!|variables |!|to |!| make |!|each |!|clause |!|have |!| 4 |!|variables. |!| For |!|both |!|cases, |!|any |!|assignment |!|of |!|C' |!|assigns |!|auxiliary |!|variables |!|true |!|or |!|false, |!|which |!|makes |!| C |!|also |!|satisfied. |!| For |!|an |!|assignment |!|satisfying |!|C, |!|C' |!|is |!|satisfied |!|without |!|added |!|variables Hitting |!|Set |!|(8.9) |!|- |!|correct |!|answer |!| Given |!|a |!|family |!|of |!|sets |!|S1...Sn...and |!|a |!|budget |!|b, |!|we |!|wish |!|to |!|find |!|a |!|set |!|H |!|<= |!|size |!|b |!|with |!|intersects |!|every |!|Si. Verifying |!|NP |!|- |!|H |!|intersect |!|with |!|every |!|Si |!|is |!|calculating |!|n |!|intersections, |!|which |!|take |!|m |!| operations, |!|so |!|O(nm). |!|

Dense |!|Subgraph |!|(8.10d) |!|- |!|correct |!|answer |!| Input: |!|A |!|graph, |!|G |!|= |!|(V, |!|E), |!|and |!|two |!|integers |!|a |!| and |!|b. Output: |!|A |!|set |!|of |!|a |!|vertices |!|V |!| |!|⊆ |!|V |!|such |!|that |!|there |!|are |!|at |!|least |!|b |!|edges |!|between |!|them. Solution |!|This |!|can |!|be |!|interpreted |!|as |!|a |!|generalization |!|of |!|the |!|independent |!|set |!|problem: |!|simply |!|let |!|a |!|= |!|g, |!|the |!|IS |!|goal, |!|and |!|let |!|b |!|= |!|0, |!|so |!|there |!|are |!|no |!|edges |!|between |!|the |!|vertices |!|(the |!| definition |!|of |!|a |!|g-sized |!|independent |!|set). This |!|can |!|also |!|be |!|viewed |!|as |!|a |!|generalization |!|of |!|the |!|clique |!|problem, |!|where |!|we |!|try |!|to |!|find |!|a |!|= |!|g |!|vertices |!|with |!|b |!|= |!|g(g−1)/2 |!|edges |!|between |!|them. |!|We |!|calculate |!|b |!|by a |!|simple |!|analysis: |!|for |!|a |!|g-sized |!|clique, |!|the |!|first |!|vertex |!|needs |!|g |!|− |!| 1 |!|edges |!|to |!|the |!|other |!| vertices, |!|the |!|second |!|needs |!|(since |!|the |!|previous |!|case |!|covered |!|(v1,v2)), |!|and |!|so |!|on. |!|This |!|comes |!|out |!|to |!|just |!|being |!|the |!|sum |!|of |!|the |!|first |!|g |!|integers Sparse |!|Subgraph |!|(8.10e) |!|- |!|correct |!|answer |!| This |!|is |!|a |!|generalization |!|of |!|INDEPENDENT |!|SET |!| problem: |!|given |!|a |!|graph |!|and |!|find |!|a |!|set |!|of |!|a |!|vertices |!|where |!|there |!|are |!|no |!|edges |!|between |!| any |!|pair |!|of |!|vertices. |!|If |!|we |!|set |!|the |!|b |!|in |!|SPARSE |!|SUBGRAPH |!|to |!|be |!|zero, |!|it |!|becomes |!| INDEPENDENT |!|SET |!|problem. Set |!|Cover |!|(8.10f) |!|- |!|correct |!|answer |!| Let |!|E |!|= |!|{e1, |!|e2, |!|.., |!|en} |!|be |!|a |!|set |!|of |!|n |!|elements. |!|Let |!| S1, |!|S2, |!|.., |!|Sm |!|be |!|subsets |!|of |!|E |!|with |!|associated |!|costs |!|c1, |!|.., |!|cm. |!|In |!|the |!|set |!|cover |!|problem, |!| our |!|goal |!|is |!|to |!|pick |!|a |!|minimum |!|cost |!|collection |!|of |!|sets |!|from |!|among |!|S1, |!|· |!|· |!|· |!|, |!|Sm, |!|such |!|that |!|the |!|union |!|of |!|these |!|sets |!|is |!|E; |!|in |!|other |!|words, |!|this |!|collection |!|"covers" |!|E. |!|The |!|set |!|cover |!| problem |!|is |!|NP-hard. it |!|is |!|a |!|generalization |!|of |!|vertex |!|cover, |!|because |!|in |!|the |!|latter, |!|we |!|can |!|think |!|of |!|the |!|edges |!|as |!| the |!|elements |!|and |!|the |!|vertices |!|as |!|sets |!|of |!|elements |!|containing |!|the |!|edges |!|incident |!|on |!|them ILP |!|can |!|also |!|encode |!|set |!|cover Reliable |!|Network |!|(8.10g) |!|- |!|correct |!|answer |!| The |!|Reliable |!|Network |!|problem |!|is |!|a |!| generalization |!|of |!|the |!|Hamiltonian |!|Cycle |!|problem. |!|Consider |!|a |!|given |!|graph |!|G=(V,E) |!|V={1, |!|..., |!|n} |!|as |!|an |!|instance |!|of |!|the |!|Hamiltonian |!|Cycle |!|Problem. |!|If |!|we |!|take |!|dij=1 |!|for |!|each |!|edge |!|ij |!|ϵ |!|E |!| and |!|dij=2 |!|for |!|each |!|edge |!|ij |!|∉E, |!|b=n, |!|and |!|every |!|rij=2 |!|then |!|this |!|is |!|equivalent |!|to |!|an |!|instance |!| of |!|the |!|Reliable |!|Network |!|problem. |!|We |!|pick |!|edges |!|such |!|that |!|the |!|weights |!|of |!|all |!|edges |!|add |!|up |!|to |!|n |!|and |!|each |!|pair |!|i,j |!|is |!|part |!|of |!|a |!|cycle. |!|This |!|would |!|mean |!|that |!|the |!|graph |!|is |!|connected |!| (since |!|each |!|pair |!|of |!|vertices |!|has |!| 2 |!|paths |!|between |!|them |!|forming |!|a |!|cycle). |!|Since |!|the |!|weight |!|

of |!|each |!|edge |!|is |!|1, |!|there |!|must |!|be |!|exactly |!|n |!|edges |!|for |!|the |!|sum |!|of |!|weights |!|to |!|be |!|n |!|and |!| exactly |!|one |!|cycle |!|since |!|there |!|are |!|exactly |!|n |!|vertices |!|and |!|n |!|edges |!|and |!|the |!|graph |!|is |!| connected. |!|Since |!|the |!|Hamiltonian |!|Cycle |!|problem |!|is |!|NP-complete, |!|the |!|Reliable |!|Network |!| problem |!|is |!|also |!|NP-complete Directed |!|Rudrata |!|Path |!|(8.11) |!|- |!|correct |!|answer |!| A) |!|directed |!|rudrata |!|path |!|-> |!|undirected. |!| Starting |!|from |!|undirected, |!|you'd |!|add |!|two |!|edges |!|(one |!|forward, |!|one |!|back) |!|to |!|make |!|a |!|directed |!|graph. B)directed |!|rudrata |!|path |!|-> |!|undirected |!|with |!|ST. |!|Add |!|forward |!|and |!|back |!|edges |!|to |!|the |!| undirected, |!|start |!|and |!|endpoints k-Spanning |!|Tree |!|(8.12) |!|- |!|correct |!|answer |!| 1) |!|Verify |!|polynomial |!|time |!|solution: |!|verify |!|that |!|S |!| has |!|no |!|cycles |!|and |!|that |!|every |!|node |!|has |!|degree |!|<=k. |!|

  1. |!|Use |!|rudrata |!|path. |!|k |!|=2. |!|A |!|tree |!|with |!|a |!|degree |!|<= |!| 2 |!|is |!|a |!|path. |!|if |!|the |!|k-spanning |!|tree |!| algo |!|says |!|a |!|path |!|exists, |!|than |!|there |!|exists |!|a |!|path |!|for |!|all |!|vertices |!|in |!|G |!|(ie |!|that's |!|the |!|rudrate |!|path). |!|If |!|there's |!|no |!|tree |!|with |!|k |!|=2, |!|then |!|there's |!|no |!|path Poly |!|or |!|NP |!|Complete? |!|8.13a: |!|A |!|set |!|of |!|nodes |!|L |!|⊆ |!|V |!|, |!|and |!|you |!|must |!|find |!|a |!|spanning |!|tree |!| such |!|that |!|its |!|set |!|of |!|leaves |!|includes |!|the |!|set |!|L |!|- |!|correct |!|answer |!| Poly. |!| Remove |!|vertices |!|in |!|L. Build |!|a |!|spanning |!|tree |!|T |!|in |!|the |!|remaining |!|graph |!|using |!|BFS |!|or |!|DFS. For |!|each |!|vertex |!|v |!|∈ |!|L, |!|connect |!|it |!|to |!|any |!|of |!|its |!|neighbor(s) |!|present |!|in |!|T |!|. If |!|some |!|vertex |!|in |!|L |!|doesn't |!|have |!|a |!|neighbor |!|in |!|T |!|, |!|then |!|we |!|cannot |!|find |!|a |!|spanning tree |!|that |!|has |!|all |!|vertices |!|in |!|L, |!|otherwise |!|the |!|spanning |!|tree |!|must |!|include |!|all |!|vertices |!|in |!|L. Poly |!|or |!|NP |!|Complete? |!|8.13b: |!|A |!|set |!|of |!|nodes |!|L |!|⊆ |!|V |!|, |!|and |!|you |!|must |!|find |!|a |!|spanning |!|tree |!| such |!|that |!|its |!|set |!|of |!|leaves |!|is |!|precisely |!|the |!|set |!|L |!|- |!|correct |!|answer |!| NP-complete. |!| (b) |!|is |!|in |!|NP. |!|Given |!|a |!|spanning |!|tree |!|T |!|, |!|we |!|can |!|verify, |!|in |!|polynomial |!|time, |!|that |!|whether |!|its |!|leaves |!|are |!|exactly |!|vertices |!|in |!|L. (b) |!|can |!|be |!|reduced |!|from |!|RUDRATA |!|(s, |!|t)-PATH. |!|Given |!|the |!|input |!|G, |!|s, |!|t |!|to |!|RUDRATA |!|(s,t)- PATH |!|problem, |!|let |!|G,L |!|:= |!|{s,t} |!|be |!|the |!|input |!|to |!|(b). |!|If |!|G |!|has |!|a |!|RUDRATA |!|(s,t)-path |!|P, |!|then |!| G |!|has |!|a |!|spanning |!|tree, |!|which |!|is |!|P, |!|with |!|the |!|set |!|of |!|its |!|leaves |!|being |!|L |!|= |!|{s, |!|t}. |!|If |!|G |!|has |!|a |!|

Input: |!|An |!|undirected |!|graph, |!|G |!|= |!|(V, |!|E) |!|and |!|a |!|integer |!|goal |!|k.Output: |!|A |!|clique |!|C |!|⊆ |!|V |!|of |!|size |!|k, |!|and |!|an |!|independent |!|set |!|S |!|⊂ |!|V |!|of |!|size k, |!|or |!|"no" |!|if |!|both |!|don't |!|exist We |!|will |!|show |!|a |!|reduction |!|from |!|the |!|IS |!|problem |!|(whose |!|input |!|is |!|(G,g)) |!|to |!|this |!|new |!|clique+IS |!|problem. Verifying |!|a |!|solution |!|to |!|the |!|Clique+IS |!|problem |!|is |!|just |!|a |!|matter |!|of |!|ver- |!|ifying |!|each |!|part |!| individually, |!|and |!|we |!|showed |!|in |!|lecture |!|that |!|this |!|can |!|be |!|done |!|in |!|polynomial |!|time |!|for |!|both. |!| Therefore, |!|this |!|problem |!|is |!|within |!|np. we |!|introduce |!|a |!|new |!|(g |!|+ |!|1)-node |!|clique, |!|Q, |!|into |!|the |!|original |!|graph. Running |!|the |!|clique+IS |!|algorithm |!|on |!|G |!|and |!|a |!|goal |!|k |!|= |!|g |!|+ |!| 1 |!|will |!|now |!|obviously |!|always |!|find |!|a |!|clique. |!|It |!|will |!|also |!|give |!|an |!|independent |!|set |!|S |!|of |!|size |!|g |!|+ |!|1, |!|but, |!|critically, |!|no |!|more |!|than |!|one |!|of |!|those |!|vertices |!|comes |!|from |!|the |!|"fake" |!|clique |!|(since |!|cliques |!|are |!|fully-connected) |!|so |!|it |!|must |!|mean |!|there |!|is |!|a |!|size |!|g |!|clique |!|in |!|the |!|original |!|graph. orward |!|Direction |!|— |!|If |!|there |!|is |!|an |!|independent |!|set |!|S |!|of |!|size |!|g |!|in |!|the |!|original |!|graph |!|G, |!| then |!|by |!|introducing |!|the |!|new |!|clique |!|to |!|craft |!|G , |!|we |!|know |!|that |!|there |!|is |!|a |!|(g+1)-sized |!|clique |!| (by |!|construction) |!|and |!|a |!|(g |!|+ |!|1)-sized |!|independent |!|set |!|(just |!|add |!|any |!|vi |!|from |!|the |!|fake |!|clique |!|to |!|S ). |!| Reverse |!|Direction—If |!|there |!|is |!|both |!|an |!|independent |!|set |!|S |!|and |!|a |!|clique |!|C |!|of |!|size |!|k |!|= |!|g |!|+ |!| 1 |!| in |!|G , |!|then |!|by |!|dropping |!|any |!|vi |!|from |!|S, |!|we |!|get |!|an |!|independent |!|set |!|of |!|size |!|g |!|(since |!|there |!| can |!|be |!|at |!|most |!|one |!|such |!|vi). |!|If |!|there |!|is |!|no |!|such |!|vi, |!|we |!|have |!|a |!|direct |!|solution |!|since |!||S| |!|≥ |!|g |!|as |!|required |!|by |!|the |!|IS |!|problem. Maximum |!|Common |!|Subgraph |!|(8.15) |!|- |!|correct |!|answer |!| Input: |!|Two |!|graphs, |!|G1 |!|= |!|(V1, |!|E1) |!| and |!|G2 |!|= |!|(V2, |!|E2) |!|and |!|a |!|budget, |!|b. Output: |!|Two |!|sets |!|of |!|vertices |!|V1 |!|⊆ |!|V1 |!|and |!|V2 |!|⊆ |!|V2 |!|such |!|that |!|deleting |!|them |!|from |!|their |!| respective |!|graphs |!|leaves |!|at |!|least |!|b |!|nodes |!|in |!|each |!|graph |!|and |!|makes |!|the |!|graphs |!|identical. Solution At |!|first |!|it |!|may |!|seem |!|that |!|this |!|has |!|a |!|relationship |!|to |!|the |!|Subgraph |!|Isomorphism |!|problem |!| above |!|(see |!|8.10a), |!|and |!|it |!|sort |!|of |!|does, |!|in |!|the |!|sense |!|that |!|all |!|of |!|the |!|graph |!|problems |!|are |!| sort |!|of |!|similar. |!|We |!|proceed |!|by |!|a |!|reduction |!|from |!|the |!|vertex |!|cover |!|problem.

Within |!|np) |!|We |!|technically |!|need |!|a |!|mapping |!|from |!|one |!|set |!|of |!|vertices |!|to |!|another |!|in |!|this |!|for |!| it |!|to |!|truly |!|be |!|verifiable |!|in |!|polynomial |!|time, |!|but |!|if |!|we |!|just |!|consider |!|equal |!|graph |!|structure |!|to |!|mean |!|equal |!|graphs, |!|then |!|it's |!|pretty |!|trivial. |!|All |!|we |!|need |!|to |!|do |!|is |!|confirm |!|that |!|the |!|amount |!| of |!|vertices |!|matches |!|(constant |!|time, |!|or |!|linear |!|if |!|your |!|data |!|structure |!|is |!|garbage) |!|and |!|that |!|the |!|edges |!|are |!|the |!|same |!|per-vertex. |!|We |!|can |!|do |!|this |!|by |!|finding |!|the |!|vertex |!|in |!|V1 |!|\ |!|V1 |!|that |!|has |!|the |!|same |!|edges |!|as |!|in |!|V2 |!|\ |!|V2 |!|in |!|O(mn) |!|time: |!|compare |!|each |!|edge |!|list |!|(which |!|is |!|≤ |!|m |!| edges |!|long) |!|of |!|each |!|vertex |!|(which |!|is |!|≤ |!|n |!|long), |!|and |!|do |!|this |!|for |!|every |!|vertex. |!|Since |!|both |!| graphs |!|could |!|be |!|fully-connected |!|in |!|the |!|worst |!|case, |!|this |!|takes |!|O(n3) |!|time |!|overall. Transformation) |!|Let |!|G1 |!|= |!|(V,E) |!|be |!|the |!|original |!|graph, |!|G2 |!|= |!|(V2,∅) |!|be |!|simply |!|b |!|disconnected |!|vertices |!|(where |!|b |!|is |!|the |!|input |!|budget |!|to |!|the |!|VC |!|problem |!|rather |!|than |!|the |!|above |!|budget), |!| and |!|the |!|budget |!|be |!|b |!|= |!|b |!|(meaning |!|nothing |!|in |!|G2 |!|gets |!|removed). |!|Then, |!|we |!|claim |!|that |!|the |!|Max-Common-Subgraph |!|problem |!|has |!|a |!|solution |!|iff |!|the |!|VC |!|problem |!|has |!|a |!|solution. Forward |!|Direction) |!|Given |!|a |!|solution |!|V |!|∗ |!|⊆ |!|V |!|to |!|the |!|VC |!|problem |!|with |!|the |!|input |!|(G, |!|b ), |!| the |!|above |!|problem |!|also |!|has |!|a |!|solution |!|since |!|one |!|could |!|simply |!|drop |!|V1 |!|= |!|V |!|∗ |!|(and |!|V2 |!|= |!| ∅, |!|so |!|no |!|action |!|there |!|is |!|required). |!|By |!|the |!|definition |!|of |!|a |!|vertex |!|cover, |!|V |!|\V1 |!|would |!|leave |!|no |!|edges |!|and |!|leave |!|exactly Experimental |!|Cuisine |!|(8.16) |!|- |!|correct |!|answer |!| Reduce |!|3SAT |!|to |!|this |!|problem. |!|The |!|columns |!| correspond |!|to |!|variables |!|and |!|the |!|rows |!|to |!|clauses. |!|A |!|winning |!|position |!|corresponds |!|to |!|a |!|value |!|assignment |!|satisfying |!|all |!|clauses |!|and |!|vice |!|versa. Show |!|that |!|any |!|problem |!|within |!|np |!|can |!|be |!|solved |!|in |!|O(2^p(n)) |!|time, |!|where |!|p(n) |!|is |!|some |!| polynomial |!|(8.17) |!|- |!|correct |!|answer |!| With |!|an |!|input |!|size |!|of |!|n |!|elements, |!|we |!|can |!|simply |!|do |!| an |!|exhaustive |!|search |!|over |!|all |!|of |!|them |!|since |!|verifying |!|their |!|correctness |!|takes |!|polynomial |!|time |!|(by |!|the |!|nature |!|of |!|being |!|within |!|np). |!|There |!|are |!|2n |!|possible |!|inputs, |!|and |!|each |!|takes |!|some |!| q(n) |!|time |!|to |!|verify |!|(where |!|q |!|is |!|the |!|verification |!|algorithm), |!|thus |!|its |!|big-O |!|is: |!|O(2^ |!|(n+q(n))) |!| or |!|2^n |!|· |!|2^q(n) Breaking |!|RSA |!|(8.18) |!|- |!|correct |!|answer |!| RSA |!|relies |!|on |!|the |!|fundamental |!|mathematical |!|difficulty |!|that |!|factoring |!|a |!|product |!|of |!|two |!|primes, |!|N |!|= |!|pq |!|is |!|not |!|doable |!|in |!|polynomial |!|time. If |!|it |!|is, |!|then |!|finding |!|the |!|separate |!|p |!|and |!|q |!|becomes |!|trivial, |!|so |!|an |!|adversary |!|can |!|find |!|φ |!|(N) |!| = |!|(p |!|− |!|1)(q |!|− |!|1) |!|and |!|compute |!|the |!|inverse |!|of |!|e |!|under |!|mod |!|φ |!|(N) |!|themselves |!|(recall |!|that |!| ed |!|≡ |!| 1 |!|(mod |!|φ |!|(N |!|))), |!|revealing |!|the |!|decryption |!|key

Transformation |!|Given |!|a |!|graph, |!|we |!|modify |!|each |!|edge |!|to |!|force |!|the |!|dominating |!|set |!|to |!|include |!|at |!|least |!|one |!|endpoint |!|and |!|result |!|in |!|a |!|valid |!|vertex |!|cover. |!|Specifically, |!|we |!|create |!|a |!|triangle |!| to |!|each |!|edge: |!|for |!|each |!|edge |!|(u, |!|v), |!|we |!|introduce |!|a |!|new |!|vertex |!|w |!|and |!|add |!|the |!|edges |!|(w, |!| u) |!|and |!|(w, |!|v). Forward |!|Direction |!|This |!|is |!|trivial: |!|a |!|vertex |!|cover |!|is |!|a |!|dominating |!|set |!|by |!|definition. |!|Since |!| every |!|edge |!|in |!|the |!|graph |!|has |!|at |!|least |!|one |!|of |!|its |!|vertices |!|in |!|the |!|VC |!|and |!|its |!|other |!|vertex |!|is |!| obviously |!|its |!|neighbor, |!|this |!|is |!|a |!|dominating |!|set. Reverse |!|Direction |!|Any |!|of |!|our |!|given |!|triangles |!|needs |!|at |!|least |!|one |!|vertex |!|to |!|be |!|within |!|D; |!|this |!|is |!|obvious—if |!|the |!|original |!|vertices |!|are |!|covered |!|by |!|the |!|dominating |!|set |!|condition |!|without |!| using |!|w, |!|then |!|w |!|is |!|left |!|out. |!|Now |!|if |!|w |!|is |!|used, |!|we |!|can |!|use |!|u |!|or |!|v |!|instead |!|and |!|still |!| maintain |!|a |!|dominating |!|set. |!|And |!|since |!|u |!|and/or |!|v |!|is |!|always |!|used |!|for |!|any |!|given |!|edge, |!|this |!|is |!|a |!|vertex |!|cover! Sequencing |!|by |!|Hybridization |!|(8.21) |!|- |!|correct |!|answer |!| In |!|this |!|problem, |!|we |!|are |!|given |!|a |!| multiset |!|(a |!|set |!|which |!|can |!|contain |!|elements |!|more |!|than |!|once) |!|of |!|something |!|called |!|k-mers—a |!| k-mer |!|is |!|a |!|substring |!|of |!|length |!|k. |!|From |!|these |!|substrings, |!|we |!|need |!|to |!|reconstruct |!|the |!|full, |!| original |!|string. We |!|say |!|that |!|Γ(x) |!|is |!|the |!|multiset |!|of |!|a |!|string |!|x's |!|k-mers. ow |!|do |!|we |!|know |!|that |!|two |!|particular |!|k-mers |!|"match"? |!|That |!|is, |!|how |!|do |!|we |!|know |!|that |!|thequ |!|and |!|hequi |!|are |!|part |!|of |!|the |!|same |!|string, |!|and |!|thequ |!|and |!|quick |!|aren't? |!|Obviously |!|because |!|the |!|2-through-kth |!|characters |!|of |!|one |!|match |!|the |!|1-through-(k |!|− |!|1)th |!|of |!|the |!|other. To |!|resolve |!|these |!|ambiguities, |!|we |!|make |!|every |!|k-mer |!|a |!|vertex |!|in |!|a |!|graph |!|and |!|connect |!|them |!| if |!|the |!|above |!|condition |!|holds. |!|We |!|use |!|a |!|different |!|string |!|with |!|3-mers |!|and |!|repeat |!|substrings We |!|need |!|to |!|prove |!|correctness, |!|though. |!|At |!|the |!|very |!|least, |!|every |!|substring |!|of |!|the |!|original |!| string |!|will |!|be |!|in |!|the |!|reconstruction, |!|since |!|the |!|Rudrata |!|path |!|will |!|touch |!|every |!|vertex |!|only |!| once. |!|If |!|there |!|are |!|duplicate |!|vertices |!|(like |!|the |!|ands |!|above), it |!|doesn't |!|matter |!|which |!|a |!|given |!|prefix |!|chooses, |!|since |!|they'll |!|all |!|have |!|the |!|same |!|incoming |!| and |!|outgoing |!|degree; |!|in |!|other |!|words, |!|duplicate |!|k-mers |!|are |!|identical |!|vertices. Feedback |!|Arc |!|Set |!|(FAS) |!|(8.22) |!|- |!|correct |!|answer |!| feedback |!|edge |!|set |!|is |!|a |!|set |!|of |!|edges |!|which, |!|when |!|removed |!|from |!|the |!|graph, |!|leave |!|a |!|DAG. |!|Put |!|another |!|way, |!|it's |!|a |!|set |!|containing |!|at |!| least |!|one |!|edge |!|of |!|every |!|cycle |!|in |!|the |!|graph.

SHow |!|NP |!|completeness |!|by |!|a |!|reduction |!|from |!|Vertex |!|Cover. |!|Make |!|a |!|directed |!|graph |!|with |!|2n |!| vertices |!|and |!|n+2|E| |!|edges |!| To |!|show |!|that |!|FAS |!|is |!|NP-hard, |!|we |!|give |!|a |!|reduction |!|from |!|VERTEX |!|COVER. |!|Let |!|G(V, |!|E), |!|k |!|be |!| an |!|instance |!|of |!|VERTEX |!|COVER, |!|which |!|we |!|transform |!|to |!|an |!|instance |!|of |!|FAS |!|G0 |!|(V |!| 0 |!|, |!|E0 |!|), |!| k0 |!|in |!|linear |!|time |!|as |!|follows: |!|For |!|every |!|vertex |!|v |!|∈ |!|V |!|, |!|we |!|add |!|two |!|corresponding |!|vertices |!| vin, |!|vout |!|∈ |!|V |!| 0 |!|that |!|we |!|connect |!|by |!|a |!|directed |!|edge |!|(vin |!|→ |!|vout), |!|and |!|for |!|every |!|edge |!|(u, |!|v) |!|∈ |!|E, |!|we |!|add |!|the |!|directed |!|edges |!|(uout |!|→ |!|vin) |!|and |!|(vout |!|→ |!|uin) |!|∗ |!|to |!|E0 |!|. |!|Finally |!|we |!| set |!|k |!| 0 |!|= |!|k; |!|and |!|claim |!|that |!|G |!|has |!|a |!|vertex |!|cover |!|of |!|size |!|at |!|most |!|k |!|iff |!|G0 |!|has |!|a |!|FAS |!|of |!| size |!|at |!|most |!|k. Suppose |!|G |!|has |!|a |!|vertex |!|cover |!|S |!|where |!||S| |!|≤ |!|k. |!|For |!|every |!|v |!|∈ |!|S, |!|consider |!|removing |!|the |!| edge |!|(vin, |!|vout) |!|in |!|G0 |!|. |!|The |!|resulting |!|graph |!|is |!|acyclic. |!|If |!|a |!|cycle |!|in |!|G0 |!|enters |!|a |!|vertex |!|in |!| vin, |!|it |!|can |!|only |!|leave |!|through |!|the |!|edge |!|(vin, |!|vout) |!|given |!|our |!|construction. |!|Similarly, |!|a |!|cycle |!|can |!|only |!|enter |!|vout |!|through |!|the |!|edge |!|(vin, |!|vout). Thus |!|if |!|a |!|cycle |!|in |!|G0 |!|uses |!|the |!|edge |!|(uout, |!|vin), |!|it |!|must |!|use |!|the |!|edge |!|(uin, |!|uout) |!|and |!|the |!| edge |!|(vin, |!|vout). |!|At |!|least |!|one |!|of |!|the |!|these |!|two |!|edges |!|would |!|have |!|been |!|removed |!|since |!|at |!| least |!|one |!|of |!|u |!|or |!|v |!|must |!|be |!|in |!|the |!|vertex |!|cover |!|to |!|cover |!|the |!|edge |!|(u, |!|v) |!|∈ |!|E. |!|Therefore |!| if |!|G |!|has |!|a |!|vertex |!|cover |!|of |!|size |!|at |!|most |!|k |!|then |!|G0 |!|has |!|a |!|feedback |!|arc |!|set |!|of |!|size |!|at |!|most |!| k |!| 0 |!|= |!|k |!|as |!|well Conversely, |!|suppose |!|G0 |!|has |!|a |!|FAS |!|S |!| 0 |!|of |!|size |!|at |!|most |!|k |!| 0 |!|. |!|Without |!|loss |!|of |!|generality, |!|we |!|assume |!|that |!|the |!|only |!|edges |!|removed |!|are |!|of |!|the |!|form |!|(uin, |!|uout) |!|because |!|if |!|some |!|other |!| edge |!|(uout, |!|vin) |!|is |!|removed, |!|then |!|all |!|cycles |!|in |!|which |!|this |!|edge |!|participated |!|would |!|have |!| included |!|the |!|edge |!|(vin, |!|vout) |!|too |!|and |!|we |!|could |!|remove |!|this |!|edge |!|instea Node-Disjoint |!|Paths |!|(8.23) |!|- |!|correct |!|answer |!| A |!|path |!|is |!|sequence |!|of |!|vertices: |!|s, |!|v_1, |!|.., |!|v_m, |!|t. |!|Two |!|paths |!|s, |!|v_1, |!|.., |!|v_m, |!|t |!|and |!|s, |!|u_1, |!|..., |!|u_k, |!|t |!|are |!|called |!|node-disjoint |!|if |!|v_i |!|!= |!|u_j |!|for |!|any |!|valid |!|i |!|and |!|j. We |!|can |!|reduce |!|this |!|problem |!|to |!|finding |!|the |!|maximum |!|number |!|of |!|edge-disjoint |!|paths |!|by |!| splitting |!|each |!|vertex |!|(except |!|for |!|the |!|source |!|and |!|the |!|target) |!|into |!|two, |!|adding |!|an |!|edge |!|from |!| the |!|first |!|copy |!|to |!|the |!|second |!|copy, |!|redirecting |!|all |!|edges |!|that |!|end |!|in |!|this |!|vertex |!|to |!|the |!|first |!| copy |!|and |!|all |!|outgoing |!|edges |!|from |!|the |!|second |!|copy. |!|After |!|that, |!|the |!|answer |!|is |!|the |!|maximum |!|flow |!|in |!|this |!|graph |!|(all |!|edges |!|should |!|have |!|a |!|unit |!|capacity).