0% found this document useful (0 votes)
42 views8 pages

CSC 305 VTL Lecture 05 2021

This document discusses the complexity of algorithms. It explains that: 1) P problems can be solved in polynomial time, while NP problems cannot necessarily be solved in polynomial time but can be verified in polynomial time. 2) NP-hard problems are at least as hard as NP-complete problems, and NP-complete problems are NP and NP-hard. 3) If a problem A can be reduced to problem B in polynomial time, then B is at least as hard as A. The hardest problems, which are both NP and NP-hard, are called NP-complete problems.

Uploaded by

Bello Taiwo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views8 pages

CSC 305 VTL Lecture 05 2021

This document discusses the complexity of algorithms. It explains that: 1) P problems can be solved in polynomial time, while NP problems cannot necessarily be solved in polynomial time but can be verified in polynomial time. 2) NP-hard problems are at least as hard as NP-complete problems, and NP-complete problems are NP and NP-hard. 3) If a problem A can be reduced to problem B in polynomial time, then B is at least as hard as A. The hardest problems, which are both NP and NP-hard, are called NP-complete problems.

Uploaded by

Bello Taiwo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Algorithm and Complexity

Course C CSC 305 / CSC 225: / Computer Science


Lecture 05: Order of Algorithms

Name Prof. A. S. Sodiya

1
Polynomial Order of Algorithms
P - Problems that can be solved in polynomial time.
P- Polynomial time solving . Problems which can be solved in polynomial time, which
take time like O(n), O(n2), O(n3). Eg: finding maximum element in an array or to check
whether a string is palindrome or not. so there are many problems which can be solved in
polynomial time.

NP - Problems that can be verified in polynomial time.


Therefore, Every P problem is also a NP as every P problem can also be verified in
polynomial time, but viceversa is not true because every NP problem cannot be solved in
polynomial time.
• NP- Non deterministic Polynomial time solving. Problem which can't be solved in
polynomial time like TSP( travelling salesman problem) or An easy example of this is
subset sum: given a set of numbers, does there exist a subset whose sum is zero?.
• but NP problems are checkable in polynomial time means that given a solution of a
problem , we can check that whether the solution is correct or not in polynomial time.
NP-Hard and NP Complete Problems
P - Problems that can be solved in polynomial time.
NP - Problems that can be verified in polynomial time.
Therefore, Every P problem is also a NP as every P problem
can also be verified in polynomial time, but viceversa is not
true because every NP problem cannot be solved in polynomial
time.
• Now here are our problems depicted in using a venn
diagram,
Reducibility
• Take two problems A and B both are NP problems.
• Reducibility- If we can convert one instance of a problem A
into problem B (NP problem) then it means that A is reducible
to B.
• NP-hard-- Now suppose we found that A is reducible to B,
then it means that B is at least as hard as A.
• NP-Complete -- The group of problems which are both in NP
and NP-hard are known as NP-Complete problem.
• Now suppose we have a NP-Complete problem R and it is
reducible to Q then Q is at least as hard as R and since R is an
NP-hard problem. therefore Q will also be at least NP-hard , it
may be NP-complete also.
NP-hard Problem
Intuitively, these are the problems that are at least as hard as the
NP-complete problems. Note that NP-hard problems do not have
to be in NP, and they do not have to be decision problems.
The precise definition here is that a problem X is NP-hard, if
there is an NP-complete problem Y, such that Y is reducible to X
in polynomial time.
But since any NP-complete problem can be reduced to any other
NP-complete problem in polynomial time, all NP-complete
problems can be reduced to any NP-hard problem in polynomial
time. Then, if there is a solution to one NP-hard problem in
polynomial time, there is a solution to all NP problems in
polynomial time.
NP-hard Problem …..
Example

The halting problem is an NP-hard problem. This is the


problem that given a program P and input I, will it halt? This is
a decision problem but it is not in NP. It is clear that any NP-
complete problem can be reduced to this one. As another
example, any NP-complete problem is NP-hard.

My favorite NP-complete problem is the Minesweeper


problem.
NP-Complete Problem
NP-Complete is a complexity class which represents the set of
all problems X in NP for which it is possible to reduce any
other NP problem Y to X in polynomial time.

Intuitively this means that we can solve Y quickly if we know


how to solve X quickly. Precisely, Y is reducible to X, if there
is a polynomial time algorithm f to transform instances y of Y
to instances x = f(y) of X in polynomial time, with the property
that the answer to y is yes, if and only if the answer to f(y) is
yes.
NP-Complete Problem…
3-SAT. This is the problem wherein we are given a conjunction (ANDs) of 3-clause disjunctions
(ORs), statements of the form

(x_v11 OR x_v21 OR x_v31) AND


(x_v12 OR x_v22 OR x_v32) AND
... AND
(x_v1n OR x_v2n OR x_v3n)
where each x_vij is a boolean variable or the negation of a variable from a finite predefined list (x_1,
x_2, ... x_n).

It can be shown that every NP problem can be reduced to 3-SAT. The proof of this is technical and
requires use of the technical definition of NP (based on non-deterministic Turing machines). This is
known as Cook's theorem.

What makes NP-complete problems important is that if a deterministic polynomial time algorithm can
be found to solve one of them, every NP problem is solvable in polynomial time (one problem to rule
them all).

You might also like