P, NP & Cook's Theorem
P, NP & Cook's Theorem
In the context of Design and Analysis of Algorithms (DAA), polynomial time refers to the time
complexity of an algorithm that can be expressed as a polynomial function of the size of the
input. An algorithm runs in polynomial time if its running time is O(n^k) for some constant k≥1.
Key Points:
1. Definition: An algorithm is said to have polynomial time complexity if the time it takes
to complete is upper-bounded by a polynomial expression in the size of the input. For
example, algorithms with time complexities like O(n2)O(n^2)O(n2), O(n3)O(n^3)O(n3),
or O(logn)O(n)O(nlogn) are considered polynomial time.
2. Significance: Polynomial time algorithms are generally regarded as efficient or feasible
for practical purposes. This is in contrast to exponential time algorithms (e.g. O(2^n) )
which grow much faster and become infeasible for large inputs.
3. P Class: Problems that can be solved by an algorithm in polynomial time are part of the
complexity class P (short for "Polynomial time"). This class is important in theoretical
computer science because it represents problems that are considered solvable efficiently.
4. Examples:
o Sorting algorithms like Merge Sort and Quick Sort have polynomial time
complexities of O(nlogn)O(n \log n)O(nlogn).
o Searching algorithms like Binary Search run in O(logn)O(\log n)O(logn) time.
o Algorithms for basic arithmetic operations like addition or multiplication have
time complexities that are polynomial in terms of the number of digits in the
input.
1. Deterministic Algorithm:
2. Non-deterministic Algorithm:
Key Differences:
Execution Path: Deterministic algorithms follow a single, predictable path, while non-
deterministic algorithms have multiple potential paths.
Output Consistency: Deterministic algorithms produce the same output for the same
input every time, whereas non-deterministic algorithms can produce different outputs due
to their hypothetical multiple execution paths.
Practicality: Deterministic algorithms are implementable and practical, whereas non-
deterministic algorithms are mainly theoretical and used for complexity analysis.
Definition of NP class Problem: - The set of all decision-based problems came into
the division of NP Problems who can't be solved or produced an output within
polynomial time but verified in the polynomial time. NP class contains P class as a
subset. NP problems being hard to solve.
Definition of Polynomial time: - If we produce an output according to the given input within a
specific amount of time such as within a minute, hours. This is known as Polynomial time.
Definition of Non-Polynomial time: - If we produce an output according to the given input but there
are no time constraints is known as Non-Polynomial time. But yes output will produce but time is not
fixed yet.
Definition of NP-hard class: - Here you to satisfy the following points to come into the
division of NP-hard
1. If we can solve this problem in polynomial time, then we can solve all NP problems in
polynomial time
2. If you convert the issue into one form to another form within the polynomial time
1. It is in NP
2. It is NP-hard
NP-hard and NP-complete are two important classifications of problems within computational
complexity theory. They describe problems based on their difficulty level in relation to the class
NP.
1. NP-Hard:
2. NP-Complete:
P⊆NP⊆NP-complete⊆NP-hard.
NP-Complete: A subset of NP that represents the most challenging problems in NP.
These problems are both in NP and as hard as any problem in NP.
NP-Hard: More general than NP-complete. NP-hard problems can be more complex
and are not required to be in NP, meaning they may not have verifiable solutions in
polynomial time.
Problem Statement
Example:
ϕ=(x1∨¬x2)∧(¬x1∨x3)∧(x2∨x3)
Output: True if there exists an assignment of truth values to the variables (x1,x2,…,xn)
such that ϕ evaluates to True. Otherwise, False.
Key Definitions
Input Formula:
ϕ=(x1∨¬x2)∧(¬x1∨x3)∧(x2∨x3)
Variables:
x1,x2,x3
Question:
Output:
True.
REDUCIBILITY
Example
COOK’s Theorem
Cook's Theorem is a fundamental result in computational complexity theory. It states that the
Boolean Satisfiability Problem (SAT) is NP-complete, meaning:
This theorem, proved by Stephen Cook in 1971, laid the foundation for the theory of NP-
completeness, which helps classify problems based on their computational difficulty.