CSE303: ADA M#5 (E-Tutorial#2) : Computational Complexity Reduction

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

Amity School of Engineering & Technology (CSE)

CSE303: ADA
M#5 [E-Tutorial#2]
Computational Complexity
Reduction

By
Anant Kumar Jayswal
anantvns20@gmail.com
M.Tech.(CSE)-JNU
PhD*(CSE)-JNU
GATE(CS), UGC-NET(CS)

1
Amity School of Engineering & Technology (CSE)

Objectives
After completing this module#5, you will be able to:
1. Differentiate between types of Problem: Trackable Vs Intractable
and Decision Vs Optimization problems.
2. Polynomial Vs non-polynomial time complexity
3. Differentiate between Complexity classes: P, NP, NP-C and NP-Hard
problem
4. Understand NP-Complete Proofs

2
Amity School of Engineering & Technology (CSE)
Trackable Problem Vs Intractable Problem

Trackable Problem Intractable Problem


Problems that can be solvable in a Some problems are intractable, as they
reasonable (polynomial) time. Some problems
grow large, areunable
we are intractable, as them
to solve they
grow large, we are unable to solve them
Polynomial time means: On an input of in polynomial time.
size n the worst-case running in polynomial time.
These problems take exponential time,
time is O() for some constant k. These
such asproblems take exponential time,
such as
For example: Sorting algorithms such as • 0/1 knapsack problem,
• 0/1 knapsack problem,
 merge-sort: O(nlogn) • Hamiltonian cycle problem,
• Hamiltonian cycle problem,
• Quicksort: O() [Worst case] • Travelling salesman problem (TSP)
• Travelling
etc. salesman problem (TSP)
• shortest path in a graph-Dijkstra’s
etc.
algorithm: O(), n: No. of vertices
• matrix multiplication: O(), etc.

3
Amity School of Engineering & Technology (CSE)
decision Problem Vs Optimization Problem

Optimization Problem Decision problem


 An optimization problem is one which  A decision problem is one with
asks, “What is the optimal solution to “yes/no” answer. In other words, a
problem X?”. In other words, we can say decision problem tries to answer a
optimization problem tries to find an yes/no question.
optimal solution.

 Example: Minimum spanning tree, 0/1  Example: Does a graph G have a


knapsack problem, MST of weight W?
 
Many problems will have decision and optimization versions, for example: Traveling
salesman problem (TSP)
• Optimization: find Hamiltonian cycle of minimum weight
• Decision: is there a Hamiltonian cycle of weight

4
Amity School of Engineering & Technology (CSE)

cla
Class of problems
Problems

Solvable Unsolvable
Problems Problems

 Halting Problem of TM
 PCB (Post
Easy Hard
correspondence Problem
Problems Problems

P Class NP Class
 Binary Search  TSP
 Quicksort, Merge Sort  Tower of Hanoi
 Dijkstra’s Algorithm  Graph coloring
 Hamiltonian Graph 5
Amity School of Engineering & Technology (CSE)

Hierarchy of Class of Problems

6
Amity School of Engineering & Technology (CSE)

P-Class
and NP-
Class of
Problems

 A Problem for which we know the algorithm and can be solved in polynomial time is
called a P-class (or Polynomial -Class) problem, such as
 Linear search, Binary Search, Merge sort, Matrix multiplication etc.
There are some problems which takes Polynomial time, and some problems takes
exponential time.
A problem which takes exponential time, or more is called NP-Class (Non-deterministic
Class) of problem.

Clearly

7
Amity School of Engineering & Technology (CSE)

P-Class and NP-Class of Problems

Table-1: Examples of P-Class and NP-Class of Problems

8
Amity School of Engineering & Technology (CSE)

P, NP, NP-Hard and NP-Complete Problems


  P = set of problems that can be solved in polynomial time. For example:
Binary search, Merge sort, Quick sort, matrix multiplication, Dijkstra’s
algorithm etc.
 NP = set of problems for which a solution can be verified in polynomial time.
Examples: 0/1 Knapsack, TSP, 3-CNF SAT, CLIQUE, VCP etc.
 A problem L is said to be NP-Hard problem if there is a polynomial time
reduction from already known NP-Hard problem to the given problem L.
Symbolically Note that L need not be in NP class.
 A problem is NP-complete if the problem is both NP-hard and in NP class.

A relationship between P, NP, NP-Complete and NP-Hard is shown as:

9
Amity School of Engineering & Technology (CSE)

P, NP, NP-Hard and NP-Complete Problems


  A problem is NP-hard if all problems in NP are polynomial time reducible to
it…., Ex:- Hamiltonian Cycle
 Every problem in NP is reducible to HC in polynomial time.
Ex:- TSP is reducible to HC.

 A problem L is said to be NP-Hard problem if there is a polynomial time


reduction from already known NP-Hard problem to the given problem L.
Symbolically Note that L need not be in NP class.
 A problem is NP-complete if the problem is both NP-hard and in NP class.

A relationship between P, NP, NP-Complete and NP-Hard is shown as:

10
Amity School of Engineering & Technology (CSE)

Relationship
between P,
NP, NP-Hard
and NP-C
Problems

Clearly
  PNP ((means any problem that can be solved by deterministic
machine in polynomial time can also be solved by non-deterministic machine
in polynomial time).
• Open question: Does P = NP?
– P ≠ NP
11
Amity School of Engineering & Technology (CSE)

Polynomial
time
Reduction of
known NP-
Complete
Problems

12
Amity School of Engineering & Technology (CSE)

Thank you!

13

You might also like