Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

DAA Unit 5 Analysis

- - - 1. Define the following with suitable examples.


(i) Class P
(ii) Class NP
(iii) NP - complete
(iv) NP – hard

Ans:
 In computer science, there exist some problems whose solutions are not yet found, the
problems are divided into classes known as Complexity Classes.
 In complexity theory, a Complexity Class is a set of problems with related complexity.
 Types of complexity classes:
1. P Class
2. NP Class
3. NP-hard
4. NP-complete
[1] P Class:
 The P in the P class stands for Polynomial Time. It is the collection of decision
problems(problems with a “yes” or “no” answer) that can be solved by a deterministic
machine in polynomial time.
 The solution to P problems is easy to find.
 P is often a class of computational problems that are solvable and tractable. Tractable means
that the problems can be solved in theory as well as in practice.
 Ex:
1) Linear Search – O(n)
2) Binary Search – O(logn)
3) Insertion Sort – O(n2)
4) Merge Sort – O(nlogn)

[2] NP Class:

 The NP in NP class stands for Non-deterministic Polynomial Time. It is the collection of


decision problems that can be solved by a non-deterministic machine in polynomial time.
 The solutions of the NP class are hard to find since they are being solved by a non-
deterministic machine but the solutions are easy to verify.
 Problems of NP can be verified by a Turing machine in polynomial time.
 They take exponential time in Deterministic machine.
 Ex:
1) Hamiltonian path – O(2n)
2) Graph colouring – O(2n)

[3] NP Hard:

 An NP-hard problem is at least as hard as the hardest problem in NP.


 All NP-hard problems are not in NP.
 It takes a long time to check them. This means if a solution for an NP-hard problem is given
then it takes a long time to check whether it is right or not.
 Consider satisfiability problem which is NP Hard,if any problem L is reduced into Satisfiability
then it also becomes NP Hard.

 Ex:
1) The Boolean Satisfiabiilty Problem
2) Traveling Salesman Problem (TSP)

[4] NP Complete:

 A problem is NP-complete if it is both NP and NP-hard.


 Ex:
1) The Boolean Satisfiability Problem
2. Explain the relationsip between class P,NP,NP-complete and NP hard problem with example of
each class.

Ans:

[1] Relationship between P and NP:


 Every deterministic problem was once an Non deterministic problem.


 According to Cook – Levine Theorem P<=NP.
 Over time we’ll try to find deterministic Polynomial time for all Non deterministic problem.

[2] Relationship between P,NP,NP Hard and NP Complete:


 NP Complete = NP Hard + NP
- - 3. Explain Cook-Levin theorem.

Ans:

4. Write a short note on :


(i) Why halting problem is called unsolvable.
(ii) In computation theory what is reduction.

5. Prove that If X is NP-complete, then X is solvable in polynomial time if and only if P = NP.

You might also like