Download presentation
Presentation is loading. Please wait.
1
CLASSES P AND NP
2
Intractability The class of problem that can be solved by non deterministic TM’s operating in polynomial time includes atleast some problems that cannot be solved by deterministic TM’s operating in polynomial time. All these problems have polynomial-time deterministic solutions or none (they may require exponential time).
3
Class P A language L is in class P if L can be recognized by a Turing machine M where M runs in polynomial time, i.e., if M is given an input w of length n, M will halt after making at most f(n) steps where f(n) is a polynomial function of n. Equivalently, a language L is in class P if there is a polynomial time algorithm to solve the problem of L.
4
Class P A problem is tractable if its language is in class P.
These are the problems we work on everyday, e.g., minimum-weight spanning-tree problem, sorting, binary search, matrix multiplication, etc. They can be solved efficiently.
5
Class P A TM M is said to be of time complexity T(n) if whenever M is given an input w of length n, M halts after making at most T(n) moves, regardless of whether or not M accepts. Examples: Any function T(n), T(n) = 50n2 Finding a MWST for a graph.
6
Finding a MWST for a graph
Solve using Kruskal’s algorithm Input: Possible code for the graph and weight limits An input of length n can represent at most O(n/log n) edges. Using Multitape TM it takes O(n2) steps to implement the algorithm. Single tape ? Extra tapes for several jobs: One to store the nodes and their current component numbers. Length is O(n) Store, Scan edges that hold least edge – weight, takes O(n) time. Find components of the two nodes connected, O(n) times Merge nodes that are to be connected.
7
Class NP A language L is in class NP if L can be recognized by a non-deterministic Turing machine M where M runs in polynomial time. Equivalently, a language L is in class NP if there is a polynomial time algorithm to check the validity of a certificate for the problem of L.
8
Class NP Examples are the Satisfiability Problem, the Traveling Salesman Problem, the Hamilton-Circuit Problem, …, etc. For example, in the TSP, we can “guess” a permutation of the nodes and “check” in polynomial time whether the total weight of this route is within the given bound, i.e., a valid certificate. If it has a hamilton circuit? Total time is O(m!), in using NTM then it is O(n2) in multitape. In single tape O(n4)
9
Class NP It is one of the top ten most important open questions in mathematics whether the class P is equal to the class NP. P = NP
10
Where is RE and CFL? NP P NPC Recursive Recursively Enumerable (RE)
Ld Where is RE and CFL? NP P NPC ULP Halting Problem Recursive Recursively Enumerable (RE) PCP Non-Recursively Enumerable (Non-RE)
11
NP-Complete A language L is NP-Complete if L itself is in NP and every language L’ in NP can be reduced to L in polynomial time. That means, for any instance I’ of the problem of L’, we can construct an instance I of the problem of L such that the answer to I is yes (no) iff the answer to I’ is yes (no).
12
NP-Hard A language L is NP-Hard if every language L’ in NP can be reduced to L in polynomial time. Note that L is not necessarily in NP itself.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.