NP HARD JAYASRI JETTI CHINMAYA KRISHNA SURYADEVARA P

  • Slides: 22
Download presentation
NP – HARD JAYASRI JETTI CHINMAYA KRISHNA SURYADEVARA

NP – HARD JAYASRI JETTI CHINMAYA KRISHNA SURYADEVARA

P and NP P – The set of all problems solvable in polynomial time

P and NP P – The set of all problems solvable in polynomial time by a deterministic Turing Machine (DTM). Example: Sorting and searching.

P and NP • NP- the set of all problems solvable in polynomial time

P and NP • NP- the set of all problems solvable in polynomial time by non deterministic Turing Machine (NDTM) • Example Partition. P is a subset of NP

NP complete • NP – Complete (NP – C): the set of all problems

NP complete • NP – Complete (NP – C): the set of all problems in NP “at least as hard” as every other problem in NP. • To prove a problem x is NP complete – Show that x is in NP – Show that some other NP - C problem reduces to x • If an NP hard problem can be solved in polynomial time, then all NP complete problems can be solved in polynomial time. • NP – H includes all NP - C problems

Deterministic and non deterministic problems • Algorithm is deterministic if for a given input

Deterministic and non deterministic problems • Algorithm is deterministic if for a given input the output generated is same for function. • A mathematical function is deterministic hence the state is known at every step of algorithm.

 • Algorithm is nondeterministic if there are more than one path the algorithm

• Algorithm is nondeterministic if there are more than one path the algorithm can take. Due to this one cannot determine the next state of the machine running the algorithm. • To specify such algorithms we introduce three statements – Choice(s) – Failure – Success - arbitrary choose one of the elements of the set S - signals an unsuccessful completion - signals a successful completion

 • Whenever there is a set of choices that leads to a successful

• Whenever there is a set of choices that leads to a successful completion than one search set of choices is always made and the algorithm terminates. • A nondeterministic algorithm terminates unsuccessfully iff there exists no set of choices leading to a successful signal

 • A machine capable of executing a nondeterministic algorithm is called a nondeterministic

• A machine capable of executing a nondeterministic algorithm is called a nondeterministic machine. • While nondeterministic machine do not exist in practice they will provide strong reason to conclude that certain problems cannot be solved by fast deterministic algorithms

 • Example of nondeterministic algorithm // the problem is to search for an

• Example of nondeterministic algorithm // the problem is to search for an element X// //output j such that A(j) = x; or j = 0 if x is not in A// j -> choice (1: n) If A(j)= x then print (j); success end if Print (‘ 0’); failure Complexity O(1); Nondeterministic decision algorithms generate a zero or 1 as their output.

Definition of classes NP - hard and NP - complete • P is a

Definition of classes NP - hard and NP - complete • P is a set of all decision problems solvable by a deterministic algorithm in polynomial time. • NP is a set of all decision problems solvable by a nondeterministic algorithm in polynomial time. • Since deterministic algorithms are special case of nondeterministic ones, we can conclude that P NP

Reducibility Let L 1 and L 2 be problems. L 1 reduces to L

Reducibility Let L 1 and L 2 be problems. L 1 reduces to L 2 (L 1 L 2) if and only if there is a deterministic polynomial time algorithm to solve L 1 that solves L 2 in polynomial time If L 1 L 2 and L 2 L 3 then L 1 L 3 Definition: NP-Hard problem: a problem L is NP hard iff satisfiability reduces to L

Definition : NP-complete Problem : • A problem L is NP-complete if and only

Definition : NP-complete Problem : • A problem L is NP-complete if and only if L is NP-hard and L є NP. • There are NP-hard problems that are not NP-complete. Example : • Halting problem is NP-hard decision problem, but it is not NP-complete. Halting Problem : • To determine for an arbitrary deterministic algorithm A and an input I whether algorithm A with input I ever terminates (or enters an infinite loop).

Halting problem is not NP-complete; but NP-hard • Halting problem is un-decidable. - Hence

Halting problem is not NP-complete; but NP-hard • Halting problem is un-decidable. - Hence there exists no algorithm to solve this problem. - So, it is not in NP. - So, it is not NP-complete. Halting problem is NP-hard • To show that Halting problem is NP-hard, we show that satisfiability is halting problem. • For this let us construct an algorithm A whose input is a prepositional formula X. - Suppose X has n variables. - Algorithm A tries out all 2 n possible truth assignments and verifies if X is satisfiable.

Halting problem is NP-hard (Contd. . ) - If it is satisfied then A

Halting problem is NP-hard (Contd. . ) - If it is satisfied then A stops. - If X is not satisfiable, then A enters an infinite loop. - Hence A halts on input iff X is satisfiable. - If we had a polynomial time algorithm for the halting problem, then we could solve the satisfiability problem in polynomial time using A and X as input to the algorithm for the halting problem. - Hence the halting problem is an NP-hard problem which is not in NP. - So it is not NP-complete.

NP-HARD GRAPH AND SCHEDULING PROBLEMS (CONTD. . ) 1. Chromatic Number Decision Problem (CNP)

NP-HARD GRAPH AND SCHEDULING PROBLEMS (CONTD. . ) 1. Chromatic Number Decision Problem (CNP) • A coloring of a graph G = (V, E) is a function f : V { 1, 2, …, k} i V. • If (U, V) E then f(u) f(v). • The CNP is to determine if G has a coloring for a given K. • Satisfiability with at most three literals per clause chromatic number problem. CNP is NP-hard.

NP-HARD GRAPH AND SCHEDULING PROBLEMS (contd. . ) 2. Directed Hamiltonian Cycle (DHC) •

NP-HARD GRAPH AND SCHEDULING PROBLEMS (contd. . ) 2. Directed Hamiltonian Cycle (DHC) • Let G = (V, E) be a directed graph and length n = V • The DHC is a cycle that goes through every vertex exactly once and then returns to the starting vertex. • The DHC problem is to determine if G has a directed Hamiltonian Cycle. Theorem : CNF (Conjunctive Normal Form) satisfiability DHC is NP-hard.

NP-HARD GRAPH AND SCHEDULING PROBLEMS (CONTD. . ) 3. Travelling Salesperson Decision Problem (TSP)

NP-HARD GRAPH AND SCHEDULING PROBLEMS (CONTD. . ) 3. Travelling Salesperson Decision Problem (TSP) : • The problem is to determine if a complete directed graph G = (V, E) with edge costs C(u, v) has a tour of cost at most M. Theorem : Directed Hamiltonian Cycle (DHC) TSP is NP-hard.

SOME SIMPLIIFIED NP-HARD PROBLEMS • An NP-hard problem L cannot be solved in deterministic

SOME SIMPLIIFIED NP-HARD PROBLEMS • An NP-hard problem L cannot be solved in deterministic polynomial time. • By placing enough restrictions on any NP hard problem, we can arrive at a polynomial solvable problem.

Examples. (i) CNF(conjuctive normal form)- Satisfiability with at most three literals per clause is

Examples. (i) CNF(conjuctive normal form)- Satisfiability with at most three literals per clause is NPhard. If each clause is restricted to have at most two literals then CNF-satisfiability is polynomial solvable (ii)Generating optimal code for a parallel assignment statement is NP-hard, - however if the expressions are restricted to be simple variables, then optimal code can be generated in polynomial time.

(iii)Generating optimal code for level one directed a- cyclic graphs is NP-hard but optimal

(iii)Generating optimal code for level one directed a- cyclic graphs is NP-hard but optimal code for trees can be generated in polynomial time. (iv)Determining if a planner graph is three colorable is NP-Hard - To determine if it is two colorable is a polynomial complexity problem.

 • https: //www. youtube. com/watch? v=CY_klh 5 u. D-E

• https: //www. youtube. com/watch? v=CY_klh 5 u. D-E

THANK YOU

THANK YOU