Design and Analysis of Algorithms
106502Module 4: Tractable and Intractable Problems
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
View this question on its own page →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 theseWorked SolutionAnswer: (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.
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
View this question on its own page →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 UndecidableWorked SolutionAnswer: (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). .
- NP-Hard: at least as hard as any NP problem (every NP problem reduces to it); may not be in NP.
- NP-Complete = NP 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
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
View this question on its own page →Which one of the following statement is correct?
(i) If and then
(ii) If and $A
otin PB
otin P$
(iii) If and then
(iv) All of theseWorked SolutionAnswer: (iv) All of these
Explanation:
Let denote polynomial-time many-one (Karp) reduction.
(i) If and then : True. Compose reduction (poly-time) with poly-time decider for → poly-time decider for . Hence is closed under .
**(ii) If and $A
otin PB
otin PBPAP$, contradiction.(iii) If and then : True — 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
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
View this question on its own page →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 calculationWorked SolutionAnswer: (iii) Polynomial-time reduction from a known NP-complete problem
Explanation:
To prove is NP-complete you must show:
- (verifiable in polytime), and
- is NP-hard: pick a known NP-complete problem (e.g., 3-SAT) and give a polynomial-time reduction .
By transitivity of , hardness of transfers to . 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)
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
View this question on its own page →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 setsWorked SolutionAnswer: (i) is a subset of
Explanation:
- and it is unknown whether (Clay Millennium problem).
- Every problem solvable in polytime (P) is also verifiable in polytime (NP) — just solve and check.
- Converse would imply , unproven.
- and are not disjoint; .
Venn: , -Complete , -Hard ⊇ -Complete (some outside ).
Correct choice: (i)
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
View this question on its own page →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-NPWorked SolutionAnswer: (iii) PSPACE
Explanation:
- QBF (Quantified Boolean Formula): given , 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 -only; co-NP is -only; PSPACE allows both via alternation.
Correct choice: (iii) PSPACE
Q2a. Write and explain the Cook's theorem.20257m
Module 4: Tractable and Intractable Problems
View this question on its own page →Write and explain the Cook's theorem.
Worked SolutionCook's Theorem (1971) — SAT is NP-Complete
Statement:
The Boolean Satisfiability problem (SAT) — given a Boolean formula in CNF, is there an assignment making 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 NP and (2) SAT is NP-hard: every NP polytime-reduces to SAT.
SAT NP: certificate = satisfying assignment, verifier checks formula in polytime.
Every NP language reduces to SAT:
- Let NP decided by nondeterministic TM in time (polynomial).
- For input , , construct Boolean formula that encodes the entire computation tableau of on : variables represent tape cells, head position, state at each time step .
- Add clauses enforcing: initial configuration = , each step follows 's transition relation, and final state is accepting.
- is satisfiable iff there exists an accepting computation path of on .
- Size of is — polynomial.
- Conversion is deterministic polytime.
Hence SAT → SAT.
Significance
- First NP-complete problem — seeds all other NP-completeness proofs by reduction from SAT.
- Implies SAT 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).
Q4b. Compare NP-hard and NP-completeness?20257m
Module 4: Tractable and Intractable Problems
View this question on its own page →Compare NP-hard and NP-completeness?
Worked SolutionNP-Hard vs NP-Completeness
Aspect NP-Hard NP-Complete Definition Problem is NP-hard if every NP reduces to in polytime: NP, . No requirement that NP. is NP-complete iff is both NP-hard and 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 ). 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 . To prove NP-complete: prove (1) NP and (2) NP-hard (reduce known NP-complete to ). 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: 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.
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
View this question on its own page →Define P-Class, NP-class, NP-complete class and NP-hard class of problems. What is the relation between them?
Worked SolutionComplexity Classes , , -Complete, -Hard — Definitions & Relations
Definitions
- (Polynomial): Decision problems solvable by deterministic TM in for some . Example: Sorting, MST, Shortest path (non-neg). Tractably solvable.
- (Nondeterministic Polynomial): Problems where yes instances have certificate verifiable in polytime by deterministic TM (equivalently solvable by nondet TM in polytime). . Example: SAT, Hamiltonian Cycle decision, Subset Sum.
- -Hard: Problem such that , (polytime reducible). No need to be in ; at least as hard as hardest in . Example: Halting Problem, TSP optimization, any NP-complete problem.
- -Complete: -Hard = hardest problems in . Formal: and , . 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 NP-complete shows it is among hardest in ; proving NP-hard shows at least as hard (possibly harder than NP).
Q7b. What is P, NP, NP hard, and NP complete? Write the relationship between all of them.20237m
Module 4: Tractable and Intractable Problems
View this question on its own page →What is P, NP, NP hard, and NP complete? Write the relationship between all of them.
Worked Solution, , -Hard, -Complete — Relationship (as in Q22)
Definitions:
- : solvable in polytime deterministic.
- : verifiable in polytime deterministic (or solvable nondet polytime).
- -Hard: every problem polytime reduces to it ( ∀∈).
- -Complete: -Hard ∧ ∈.
Relations:
- , unknown equality.
- -Complete = ∩ -Hard.
- iff some (equivalently all) -complete ∈ .
- -Hard includes undecidable problems outside (e.g., Halting) → strictly larger.
Diagram concept: Draw big rectangle of all problems, big oval -Hard overlapping; inside oval, smaller oval ; inside , region and ring -Complete at hardest edge of overlapping -Hard.
Proving -complete: Show (certificate verifier) + reduce known -complete .
- Install PocketlyBudget 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.
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
View this question on its own page →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?Worked SolutionComplexity Classes & Cook's Theorem — Summary
(i) , , -Complete, -Hard (as in Q22)
- : polytime solvable deterministic — tractable.
- : polytime verifiable (nondet polytime). .
- -Hard: every ≤ it.
- -Complete: -Hard ∩ — hardest in .
(ii) Cook's Theorem
SAT (and 3-SAT) is NP-complete. Statement: For any with nondet TM running in , there is polytime construction poly-size CNF such that 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 iff SAT∈.
- 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).
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
View this question on its own page →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.Worked SolutionPolynomial-Time Reduction & NP-Completeness via 3-SAT → Vertex Cover
(i) Polynomial-Time Reduction
Many-one Karp reduction : deterministic algorithm transforming any instance of into instance of in time such that . Implies if then ; transitivity holds; orders hardness.
(ii) Use to Prove NP-Completeness
To prove NP-complete: show + pick known NP-complete (e.g., 3-SAT) and show . By transitivity every problem reduces to reduces to → NP-hard; with → 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 and integer , is there , covering all edges?Construction: Given 3-SAT formula with vars, clauses.
- Variable gadget: For each variable , create two vertices , with edge . Cover must pick at least one per gadget (choosing truth assignment).
- Clause gadget: For each clause , create triangle of 3 vertices 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., — literal 's variable node). This forces covering choice to correspond to satisfying literal.
- Set .
Claim: Formula satisfiable ⇔ graph has vertex cover of size ≤ .
- ⇒ 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 , 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 ( vertices/edges). Since 3-SAT NP-complete → Vertex Cover NP-hard; clearly ∈NP (certificate = cover, verifier checks edges) → NP-complete.