ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCOMP3138Np Completeness Proofs
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    COMP3138

    Design and Analysis of Algorithms

    Progress0 / 53 done
    Topics53
    1Introduction to Algorithm Design2Data Structures3Efficiency in Algorithms4Analysis of Algorithms5Mathematical Review6Mathematical Analysis of Algorithms7Types of Functions8Order of Growth9Asymptotic Notations10Sorting Algorithms11Selection Sort Algorithm12Example and Analysis of Selection Sort13Insertion Sort Algorithm14Divide and Conquer Algorithms15Merge Sort Algorithm16Quick Sort Algorithm17Bucket Sort Algorithm18Radix Sort Algorithm19Counting Sort Algorithm20Heap Sort Basics21Heap Algorithms22Heap Properties and Examples23Heap Operations24Heap Sort Algorithm Analysis25Heap Insertion and Deletion26Tree Based Algorithms and Hashing27Red Black Tree Basics28Binary Search Tree Basics29Tree Searching Algorithms30Analysis of Tree Searching Algorithms31Analysis of Insertion and Deletion in BST32Hashing Basics33Examples of Hash Functions34Analysis of Collision Resolution Techniques35Dynamic Programming360-1 Knapsack Problem37Fractional Knapsack Problem38Longest Common Subsequence39Shortest Path Finding40Matrix Chain Multiplication41Assembly Line Chain Problem42Greedy Algorithms43Prim's Algorithm44Kruskal's Algorithm45Dijkstra's Algorithm46Huffman Coding47NP-Completeness48Polynomial Time Verification49Reducibility50NP-Completeness Proofs51Randomized Algorithms52Particle Swarm Optimization53Genetic Algorithms
    9 min read
    Topic 50 of 53
    Topic Study Note Illustration
    50

    NP-Completeness Proofs

    An NP-completeness proof is used to show that a problem is both in NP and NP-hard . These two properties are crucial in establishing that a problem...

    NP-Completeness Proofs

    An NP-completeness proof is used to show that a problem is both in NP and NP-hard. These two properties are crucial in establishing that a problem is NP-complete:

    1. In NP: A problem is in NP if, given a solution, we can verify whether it is correct in polynomial time.
    2. NP-hard: A problem is NP-hard if every problem in NP can be reduced to it in polynomial time.

    A problem is NP-complete if it satisfies both of these properties. Let's break down how we go about proving that a problem is NP-complete.

    Steps to Prove NP-Completeness

    To prove that a problem PPP is NP-complete, we follow these general steps:

    1. Prove that the problem is in NP:

      • We need to show that the problem is in NP, which means that given a candidate solution, we can verify whether it’s correct in polynomial time.
      • This step is typically straightforward. For example, in the Traveling Salesman Problem (TSP), given a tour of cities, you can check in polynomial time if the tour visits every city exactly once and whether the total distance is less than a given threshold.
    2. Prove that the problem is NP-hard:

      • To show that a problem is NP-hard, we reduce a known NP-complete problem to PPP in polynomial time.
      • If we can show that a known NP-complete problem can be transformed into PPP, we can conclude that PPP is NP-hard. This is because if we could solve PPP efficiently, we could solve the NP-complete problem efficiently as well, which would imply that P = NP.
      • The reduction is usually done from a well-established NP-complete problem such as SAT, 3-SAT, Clique, Vertex Cover, or Knapsack.

    Detailed Steps in NP-Completeness Proofs

    Step 1: Proving the Problem is in NP

    For any problem PPP to be in NP, we need to show that, given a candidate solution, it can be verified in polynomial time. This step is typically straightforward and involves constructing a verification algorithm that checks if the proposed solution satisfies the conditions of the problem.

    Example: For the Subset Sum Problem, given a subset of integers, we need to verify if the sum of the subset equals a given target sum. The verification process involves summing the integers in the subset and checking if the result matches the target. This can clearly be done in polynomial time.

    Step 2: Proving the Problem is NP-Hard

    To prove that a problem is NP-hard, we must show that we can reduce an existing NP-complete problem to the given problem PPP. This is typically done in one of the following ways:

    1. Choosing a Known NP-Complete Problem: We start by picking a well-known NP-complete problem that has already been proven to be in NP and NP-hard. Common choices include:

      • 3-SAT (Boolean satisfiability)
      • Clique (Finding a complete subgraph in a graph)
      • Vertex Cover (Finding the smallest set of vertices that touch all edges in a graph)
      • Subset Sum (Determining if there is a subset of integers that sum to a given value)
      • Knapsack (Maximizing the value of items taken while adhering to a weight limit)
    2. Reducing the Problem: The key step in the proof is the reduction: transforming an instance of the known NP-complete problem into an instance of the problem PPP in polynomial time. The reduction must preserve the solution; in other words, a solution to the transformed problem must correspond to a solution to the original problem.

    3. Proving Correctness of the Reduction: After performing the reduction, we need to show that solving the transformed problem will allow us to solve the original NP-complete problem.

    Example: Proving 3-SAT is NP-Complete

    Let’s walk through the proof that 3-SAT is NP-complete as an example.

    1. Prove that 3-SAT is in NP:

      • Given a proposed truth assignment for the boolean variables, we can easily check whether this assignment satisfies the 3-SAT formula. This check involves going through all the clauses of the formula and verifying that each clause is true under the given assignment. This can be done in polynomial time.
    2. Prove that 3-SAT is NP-Hard:

      • To prove that 3-SAT is NP-hard, we need to reduce a known NP-complete problem to 3-SAT. One of the most common reductions is from SAT (the general satisfiability problem) to 3-SAT.

      • The SAT problem allows clauses of any size (e.g., a clause could have more than 3 literals). To reduce SAT to 3-SAT, we need to ensure that every clause has exactly 3 literals. We can do this by introducing new variables and transforming larger clauses into a series of smaller clauses, each of which has 3 literals. This is known as a clause transformation.

      • For example:

        • If a clause in SAT is (x∨y∨z∨w)(x \vee y \vee z \vee w)(x∨y∨z∨w), we can break it into two clauses in 3-SAT as follows:
          • (x∨y∨z)(x \vee y \vee z)(x∨y∨z)
          • neg z \vee w) $$
        • The reduction preserves satisfiability because a solution to the original SAT formula will also satisfy the transformed 3-SAT formula and vice versa.

    Thus, by reducing SAT to 3-SAT in polynomial time, we show that 3-SAT is NP-hard.

    Example of a Full NP-Completeness Proof: Vertex Cover Problem

    Let’s go through a detailed proof of NP-completeness for the Vertex Cover Problem.

    Problem: Given a graph G=(V,E)G = (V, E)G=(V,E) and an integer kkk, is there a set of kkk vertices such that every edge in GGG is incident to at least one vertex in the set?

    Step 1: Prove that Vertex Cover is in NP

    • Given a set of kkk vertices, we can check in polynomial time whether every edge in the graph has at least one endpoint in the set. This involves going through each edge and verifying if at least one of its endpoints is in the set. This check can be done in linear time relative to the number of edges, so verifying the solution is clearly in NP.

    Step 2: Prove that Vertex Cover is NP-Hard

    • To prove that the Vertex Cover Problem is NP-hard, we reduce an already known NP-complete problem to it. A common choice is to reduce from the 3-SAT Problem to Vertex Cover.
    Reduction from 3-SAT to Vertex Cover
    • 3-SAT Instance: Given a 3-SAT formula with mmm clauses and nnn variables, we want to determine if there is a satisfying assignment to the variables.

    • Graph Construction: We construct a graph based on the clauses and variables in the 3-SAT formula:

      • For each variable, create two vertices, one for the literal and one for its negation.
      • For each clause in the 3-SAT formula, create a triangle in the graph that represents the literals in that clause. Each vertex in the triangle corresponds to a literal in the clause.
    • Vertex Cover Construction: The goal is to find a set of kkk vertices such that every edge in the graph is covered by at least one vertex in the set. If we choose k=2n+mk = 2n + mk=2n+m, the vertex cover will correspond to choosing a satisfying assignment for the 3-SAT formula.

    • Why the Reduction Works: The reduction works because if a satisfying assignment exists, there will be a way to select kkk vertices that cover all the edges in the graph, reflecting the assignment’s truth values. Conversely, a valid vertex cover corresponds to a satisfying assignment for the 3-SAT formula.

    Thus, by reducing 3-SAT to the Vertex Cover Problem, we prove that Vertex Cover is NP-hard.

    Conclusion

    To prove that a problem is NP-complete, we need to demonstrate two things:

    1. The problem is in NP (its solution can be verified in polynomial time).
    2. The problem is NP-hard (we can reduce a known NP-complete problem to it in polynomial time).

    A typical NP-completeness proof involves selecting an appropriate known NP-complete problem, performing a polynomial-time reduction, and verifying that the solution to the reduced problem corresponds to a solution to the original problem. By following this approach, we can show that a problem is NP-complete and therefore likely does not have an efficient solution unless P=NPP = NPP=NP.

    ← Previous topic 49
    Reducibility
    Next topic 51 →
    Randomized Algorithms

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    9mremaining
    1.5kwords
    Intermediatelevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Design and Analysis of Algorithms