Design and Analysis of Algorithms

106502
Back to Design and Analysis of Algorithms

Module 4: Tractable and Intractable Problems

  1. Q1e. Which one is true of the following (i) all NP hard problems are NP complete (ii) all NP complete problems are NP hard (iii) some NP complete problems are NP hard (iv) None of these20222m

    Module 4: Tractable and Intractable Problems

    Which one is true of the following
    (i) all NP hard problems are NP complete
    (ii) all NP complete problems are NP hard
    (iii) some NP complete problems are NP hard
    (iv) None of these

    View this question on its own page →
    Worked Solution

    Answer: (ii) all NP complete are NP hard

    NP-complete = NP ∩ NP-hard. All NP-complete are NP-hard and in NP; not all NP-hard are NP-complete (some not in NP). So (ii) true, (i) false.

  2. Q1h. Which complexity class contains problems for which a given solution can be verified in polynomial time by a deterministic Turing machine? (i) Class P (ii) Class NP (iii) Class NP-Hard (iv) Class Undecidable20252m

    Module 4: Tractable and Intractable Problems

    Which complexity class contains problems for which a given solution can be verified in polynomial time by a deterministic Turing machine?

    (i) Class P
    (ii) Class NP
    (iii) Class NP-Hard
    (iv) Class Undecidable

    View this question on its own page →
    Worked Solution

    Answer: (ii) Class NP

    Explanation:

    • P: problems solvable in polynomial time by a deterministic TM.
    • NP: problems where a proposed solution (certificate) can be verified in polynomial time by a deterministic TM (equivalently, solvable in polynomial time by a non-deterministic TM). P⊆NPP \subseteq NP.
    • NP-Hard: at least as hard as any NP problem (every NP problem reduces to it); may not be in NP.
    • NP-Complete = NP ∩\cap NP-Hard.
    • Undecidable: no TM can solve all instances.

    The definition "verifiable in polynomial time by deterministic TM" is exactly NP.

    Correct choice: (ii) Class NP

  3. Q1i. Which one of the following statement is correct? (i) If A \le_p B and B \in P then A \in P (ii) If A \le_p B and $A otin P then B otin P$ (iii) If A \le_p B and B \le_p C then A \le_p C (iv) All of these20222m

    Module 4: Tractable and Intractable Problems

    Which one of the following statement is correct?
    (i) If A≤pBA \le_p B and B∈PB \in P then A∈PA \in P
    (ii) If A≤pBA \le_p B and $A
    otin Pthen then B
    otin P$
    (iii) If A≤pBA \le_p B and B≤pCB \le_p C then A≤pCA \le_p C
    (iv) All of these

    View this question on its own page →
    Worked Solution

    Answer: (iv) All of these

    Explanation:

    Let A≤pBA \le_p B denote polynomial-time many-one (Karp) reduction.

    • (i) If A≤pBA \le_p B and B∈PB \in P then A∈PA \in P: True. Compose reduction ff (poly-time) with poly-time decider for BB → poly-time decider for AA. Hence PP is closed under ≤p\le_p.

    • **(ii) If A≤pBA \le_p B and $A
      otin Pthen then B
      otin P∗∗:True—contrapositiveof(i).If**: True — contrapositive of (i). If Bwerein were in P,(i)wouldput, (i) would put Ain in P$, contradiction.

    • (iii) If A≤pBA \le_p B and B≤pCB \le_p C then A≤pCA \le_p C: True — ≤p\le_p is transitive; compose the two poly-time reduction functions (polynomial of polynomial is polynomial).

    All three are fundamental lemmas used in NP-completeness proofs.

    Correct choice: (iv) All of these

  4. Q1i. What is the primary technique used to prove that a problem is NP-complete? (i) Divide and conquer (ii) Dynamic programming (iii) Polynomial-time reduction from a known NP-complete problem (iv) Space complexity calculation20242m

    Module 4: Tractable and Intractable Problems

    What is the primary technique used to prove that a problem is NP-complete?
    (i) Divide and conquer
    (ii) Dynamic programming
    (iii) Polynomial-time reduction from a known NP-complete problem
    (iv) Space complexity calculation

    View this question on its own page →
    Worked Solution

    Answer: (iii) Polynomial-time reduction from a known NP-complete problem

    Explanation:

    To prove LL is NP-complete you must show:

    1. L∈NPL \in NP (verifiable in polytime), and
    2. LL is NP-hard: pick a known NP-complete problem L0L_0 (e.g., 3-SAT) and give a polynomial-time reduction L0≤pLL_0 \le_p L.

    By transitivity of ≤p\le_p, hardness of L0L_0 transfers to LL. Subsequent proofs often use Cook's theorem (SAT is NP-complete) as base.

    Divide-and-conquer / DP / space calculation do not establish NP-hardness.

    Correct choice: (iii)

  5. Q1j. What is the relationship between NP and P complexity classes? (i) P is a subset of NP (ii) NP is a subset of P (iii) P and NP are equivalent (iv) P and NP are disjoint sets20232m

    Module 4: Tractable and Intractable Problems

    What is the relationship between NP and P complexity classes?
    (i) P is a subset of NP
    (ii) NP is a subset of P
    (iii) P and NP are equivalent
    (iv) P and NP are disjoint sets

    View this question on its own page →
    Worked Solution

    Answer: (i) PP is a subset of NPNP

    Explanation:

    • P⊆NPP \subseteq NP and it is unknown whether P=NPP = NP (Clay Millennium problem).
    • Every problem solvable in polytime (P) is also verifiable in polytime (NP) — just solve and check.
    • Converse NP⊆PNP \subseteq P would imply P=NPP=NP, unproven.
    • PP and NPNP are not disjoint; P∩NP=PP \cap NP = P.

    Venn: P⊆NPP \subseteq NP, NPNP-Complete ⊂NP\subset NP, NPNP-Hard ⊇ NPNP-Complete (some outside NPNP).

    Correct choice: (i)

  6. Q1j. The Quantified Boolean Formula problem is a canonical complete problem for which of the following complexity classes? (i) NP (ii) P (iii) PSPACE (iv) co-NP20252m

    Module 4: Tractable and Intractable Problems

    The Quantified Boolean Formula problem is a canonical complete problem for which of the following complexity classes?

    (i) NP
    (ii) P
    (iii) PSPACE
    (iv) co-NP

    View this question on its own page →
    Worked Solution

    Answer: (iii) PSPACE

    Explanation:

    • QBF (Quantified Boolean Formula): given ∃x1∀x2∃x3…ϕ(x1,…,xn)\exists x_1 \forall x_2 \exists x_3 \dots \phi(x_1,\dots,x_n), is it true? It extends SAT with quantifiers.
    • QBF is PSPACE-complete (Stockmeyer-Meyer 1973). SAT is NP-complete; QBF with unbounded alternation captures polynomial-space computation.
    • Complete for PSPACE under polytime reductions → canonical PSPACE-complete problem.
    • NP is ∃\exists-only; co-NP is ∀\forall-only; PSPACE allows both via alternation.

    Correct choice: (iii) PSPACE

  7. Q2a. Write and explain the Cook's theorem.20257m

    Module 4: Tractable and Intractable Problems

    Write and explain the Cook's theorem.

    View this question on its own page →
    Worked Solution

    Cook's Theorem (1971) — SAT is NP-Complete

    Statement:
    The Boolean Satisfiability problem (SAT) — given a Boolean formula ϕ\phi in CNF, is there an assignment making ϕ\phi true? — is NP-complete.

    More precisely Cook proved CNF-SAT is NP-complete; Levin independently proved general SAT. Hence 3-SAT is also NP-complete.

    Proof Idea

    Must show (1) SAT ∈\in NP and (2) SAT is NP-hard: every L∈L \in NP polytime-reduces to SAT.

    1. SAT ∈\in NP: certificate = satisfying assignment, verifier checks formula in polytime.

    2. Every NP language reduces to SAT:

      • Let L∈L \in NP decided by nondeterministic TM MM in time p(n)p(n) (polynomial).
      • For input xx, ∣x∣=n|x|=n, construct Boolean formula ϕx\phi_x that encodes the entire computation tableau of MM on xx: variables represent tape cells, head position, state at each time step t=0..p(n)t=0..p(n).
      • Add clauses enforcing: initial configuration = xx, each step follows MM's transition relation, and final state is accepting.
      • ϕx\phi_x is satisfiable iff there exists an accepting computation path of MM on xx.
      • Size of ϕx\phi_x is O(p(n)2)O(p(n)^2) — polynomial.
      • Conversion x↦ϕxx \mapsto \phi_x is deterministic polytime.
        Hence x∈L  ⟺  ϕx∈x \in L \iff \phi_x \in SAT → L≤pL \le_p SAT.

    Significance

    • First NP-complete problem — seeds all other NP-completeness proofs by reduction from SAT.
    • Implies P=NP  ⟺  P = NP \iff SAT ∈\in P.
    • Foundations of complexity theory; Karp's 1972 paper reduced SAT to 21 other combinatorial problems (Clique, Vertex Cover, Hamiltonian Cycle), establishing NP-completeness as pervasive.

    Corollary

    3-SAT (each clause has exactly 3 literals) remains NP-complete via simple reduction from SAT (splitting long clauses with auxiliary variables).

  8. Q4b. Compare NP-hard and NP-completeness?20257m

    Module 4: Tractable and Intractable Problems

    Compare NP-hard and NP-completeness?

    View this question on its own page →
    Worked Solution

    NP-Hard vs NP-Completeness

    Aspect NP-Hard NP-Complete
    Definition Problem HH is NP-hard if every L∈L\in NP reduces to HH in polytime: ∀L∈\forall L\in NP, L≤pHL\le_p H. No requirement that H∈H\in NP. CC is NP-complete iff CC is both NP-hard and C∈C\in NP. So NP-C = NP ∩ NP-hard.
    Verifiable? Not necessarily verifiable in polytime; may be harder than NP (e.g., Halting, undecidable problems are NP-hard). Yes, must be verifiable in polytime (certificate check O(nk)O(n^k)).
    Examples Halting Problem, 3-SAT optimization version, TSP optimization; also any NP-complete problem is NP-hard. Decision versions: SAT, 3-SAT, Clique decision, Vertex Cover decision, Hamiltonian Cycle, Subset Sum decision, TSP decision (is there tour ≤K?).
    Reduction direction To prove NP-hard: reduce known NP-hard/NP-complete L0≤pHL_0 \le_p H. To prove NP-complete: prove (1) C∈C\in NP and (2) CC NP-hard (reduce known NP-complete to CC).
    Solvability If NP-hard problem in P → P=NP, but converse not. NP-hard outside NP cannot be in NP regardless of P vs NP. If any NP-complete in P → P=NP → all NP problems polytime.
    Optimization vs Decision Optimization forms often NP-hard but not NP-complete because verification of optimality not polytime (just decision version is NP-complete). Decision versions with yes/no and polytime verifier.

    Venn: P⊆P \subseteq NP, NP-Complete ⊂ NP, NP-Hard superset overlapping NP (contains NP-C) and extending outside.

    Consequence: Showing new problem NP-complete establishes it is among hardest in NP; showing NP-hard shows at least as hard as NP-complete, possibly harder/undecidable.

  9. Q7b. Define P-Class, NP-class, NP-complete class and NP-hard class of problems. What is the relation between them?20227m

    Module 4: Tractable and Intractable Problems

    Define P-Class, NP-class, NP-complete class and NP-hard class of problems. What is the relation between them?

    View this question on its own page →
    Worked Solution

    Complexity Classes PP, NPNP, NPNP-Complete, NPNP-Hard — Definitions & Relations

    Definitions

    • PP (Polynomial): Decision problems solvable by deterministic TM in O(nk)O(n^k) for some kk. Example: Sorting, MST, Shortest path (non-neg). Tractably solvable.
    • NPNP (Nondeterministic Polynomial): Problems where yes instances have certificate verifiable in polytime by deterministic TM (equivalently solvable by nondet TM in polytime). P⊆NPP\subseteq NP. Example: SAT, Hamiltonian Cycle decision, Subset Sum.
    • NPNP-Hard: Problem HH such that ∀L∈NP\forall L\in NP, L≤pHL\le_p H (polytime reducible). No need to be in NPNP; at least as hard as hardest in NPNP. Example: Halting Problem, TSP optimization, any NP-complete problem.
    • NPNP-Complete: NP∩NP \cap NPNP-Hard = hardest problems in NPNP. Formal: C∈NPC\in NP and ∀L∈NP\forall L\in NP, L≤pCL\le_p C. Cook proved SAT is NP-complete. Example: 3-SAT, Clique, Vertex Cover decision, Hamiltonian Cycle.

    Relations

    P ⊆ NP   (unknown if equal — Clay Millennium)
    NP-Complete ⊂ NP
    NP-Complete ⊂ NP-Hard
    NP-Hard extends outside NP (includes undecidable)
    P = NP  ⇔  some NP-complete ∈ P  ⇔  all NP-complete ∈ P
    If any NP-hard problem outside NP is in P, not relevant (still P vs NP open).
    

    Venn diagram: Large oval NP-Hard; inside it smaller oval NP; within NP: P region and NP-Complete ring (NP-Complete = intersection of NP-Hard with NP). Outside NP-Hard? None — NP-Hard superset.

    Consequences: Proving new problem XX NP-complete shows it is among hardest in NPNP; proving NP-hard shows at least as hard (possibly harder than NP).

  10. Q7b. What is P, NP, NP hard, and NP complete? Write the relationship between all of them.20237m

    Module 4: Tractable and Intractable Problems

    What is P, NP, NP hard, and NP complete? Write the relationship between all of them.

    View this question on its own page →
    Worked Solution

    PP, NPNP, NPNP-Hard, NPNP-Complete — Relationship (as in Q22)

    Definitions:

    • PP: solvable in polytime deterministic.
    • NPNP: verifiable in polytime deterministic (or solvable nondet polytime).
    • NPNP-Hard: every NPNP problem polytime reduces to it (L≤pHL\le_p H ∀LL∈NPNP).
    • NPNP-Complete: NPNP-Hard ∧ ∈NPNP.

    Relations:

    • P⊆NPP \subseteq NP, unknown equality.
    • NPNP-Complete = NPNP ∩ NPNP-Hard.
    • P=NPP = NP iff some (equivalently all) NPNP-complete ∈ PP.
    • NPNP-Hard includes undecidable problems outside NPNP (e.g., Halting) → strictly larger.

    Diagram concept: Draw big rectangle of all problems, big oval NPNP-Hard overlapping; inside oval, smaller oval NPNP; inside NPNP, region PP and ring NPNP-Complete at hardest edge of NPNP overlapping NPNP-Hard.

    Proving XX NPNP-complete: Show X∈NPX∈NP (certificate verifier) + reduce known NPNP-complete Y≤pXY \le_p X.

  11. Budget App•POCKETLY

    Pocketly on Android

    Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

    Install Pocketly
  12. Q8a. Answer the following: (i) Describe complexity classes P, NP, NP-complete, and NP-hard. (ii) State and explain Cook's Theorem. (iii) Why is it considered a foundational result in computational complexity theory?20247m

    Module 4: Tractable and Intractable Problems

    Answer the following:
    (i) Describe complexity classes P, NP, NP-complete, and NP-hard.
    (ii) State and explain Cook's Theorem.
    (iii) Why is it considered a foundational result in computational complexity theory?

    View this question on its own page →
    Worked Solution

    Complexity Classes & Cook's Theorem — Summary

    (i) PP, NPNP, NPNP-Complete, NPNP-Hard (as in Q22)

    • PP: polytime solvable deterministic — tractable.
    • NPNP: polytime verifiable (nondet polytime). P⊆NPP\subseteq NP.
    • NPNP-Hard: every NPNP ≤p_p it.
    • NPNP-Complete: NPNP-Hard ∩ NPNP — hardest in NPNP.

    (ii) Cook's Theorem

    SAT (and 3-SAT) is NP-complete. Statement: For any L∈NPL∈NP with nondet TM MM running in p(n)p(n), there is polytime construction x↦φxx↦ φ_x poly-size CNF such that x∈L⇔φxx∈L ⇔ φ_x satisfiable. See Q86 proof sketch (tableau encoding). Converse SAT∈NP via assignment verifier.

    (iii) Why Foundational

    • First NP-complete problem — provides base for all NP-completeness reductions (Karp's 21 problems).
    • Establishes existence of hardest NP problems; implies P=NPP=NP iff SAT∈PP.
    • Launched theory of NP-completeness, guiding algorithm design (choose approximation/heuristic when NP-hard).
    • Connects logic, computation, and combinatorics; Levin independently discovered similar (Cook-Levin theorem).
    • Practical: SAT solvers despite NP-completeness handle huge instances (industrial use).
  13. Q8b. Answer the following: (i) What is polynomial-time reduction? (ii) How is it used to prove that a problem is NP-complete? (iii) Explain the process of reducing 3-SAT to Vertex Cover.20247m

    Module 4: Tractable and Intractable Problems

    Answer the following:
    (i) What is polynomial-time reduction?
    (ii) How is it used to prove that a problem is NP-complete?
    (iii) Explain the process of reducing 3-SAT to Vertex Cover.

    View this question on its own page →
    Worked Solution

    Polynomial-Time Reduction & NP-Completeness via 3-SAT → Vertex Cover

    (i) Polynomial-Time Reduction

    Many-one Karp reduction A≤pBA ≤_p B: deterministic algorithm transforming any instance xx of AA into instance f(x)f(x) of BB in time poly(∣x∣)poly(|x|) such that x∈A⇔f(x)∈Bx∈A ⇔ f(x)∈B. Implies if B∈PB∈P then A∈PA∈P; transitivity holds; ≤p≤_p orders hardness.

    (ii) Use to Prove NP-Completeness

    To prove BB NP-complete: show B∈NPB∈NP + pick known NP-complete AA (e.g., 3-SAT) and show A≤pBA ≤_p B. By transitivity every NPNP problem reduces to AA reduces to BB → BB NP-hard; with B∈NPB∈NP → NP-complete.

    (iii) Reduction 3-SAT → Vertex Cover (Sketch)

    3-SAT: Conjunctive normal form with 3 literals per clause, decide satisfiability.
    Vertex Cover decision: Given G(V,E)G(V,E) and integer kk, is there C⊆VC⊆V, ∣C∣≤k|C|≤k covering all edges?

    Construction: Given 3-SAT formula with nn vars, mm clauses.

    • Variable gadget: For each variable xix_i, create two vertices xix_i, xˉi\bar x_i with edge (xi,xˉi)(x_i,\bar x_i). Cover must pick at least one per gadget (choosing truth assignment).
    • Clause gadget: For each clause Cj=(la∨lb∨lc)C_j = (l_a ∨ l_b ∨ l_c), create triangle of 3 vertices aj,bj,cja_j,b_j,c_j with edges among them. Cover must pick at least 2 of 3 per triangle.
    • Connection edges: Connect each triangle vertex to its literal vertex (e.g., aja_j — literal lal_a's variable node). This forces covering choice to correspond to satisfying literal.
    • Set k=n+2mk = n + 2m.

    Claim: Formula satisfiable ⇔ graph has vertex cover of size ≤ kk.

    • ⇒ If assignment satisfies, pick per variable the true literal vertex, per clause pick 2 triangle vertices covering clause's false literals (at least one literal true, so the edge to its variable vertex is already covered, allowing to pick the other two triangle vertices).
    • ⇐ If cover size kk, it must use exactly 1 per variable gadget and 2 per clause triangle. Extract assignment from variable vertices in cover; each clause triangle leaves one literal uncovered → that literal's edge must be covered by its variable vertex → that literal true → clause satisfied.

    Reduction is polytime (O(n+m)O(n+m) vertices/edges). Since 3-SAT NP-complete → Vertex Cover NP-hard; clearly ∈NP (certificate = cover, verifier checks edges) → NP-complete.