- Related Questions & Answers
- What is NP-completeness in TOC?
- What are the differences between class methods and class members in C#?
- What are Object and Class in Perl?
- What are the differences between an Exception class and an Error class in Java?
- Prove that the Hamiltonian Path is NP-Complete in TOC
- Prove that the vertex cover is NP complete in TOC
- Character class \p{javaUpperCase} Java regex.
- Character class \p{javaMirrored} Java regex.
- Character class \p{javaLowerCase} Java regex.
- What are the differences between struct and class in C++?
- What are class instances in C#?
- What are the differences between a class and struct in C#?
- What are public and private variables in Python class?
- What are the methods and properties of the Thread class in C#?
- Character class \p{javaWhitespace} Java regex in java.

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

To begin with, let us learn about the P class in the theory of computation (TOC).

**P-Class**

The class P consists of those problems that are solvable in polynomial time, i.e. these problems can be solved in time O(n k) in the worst-case, where k is constant.

These types of problems are called tractable and others are called intractable or super polynomial.

Generally, an algorithm is a polynomial time algorithm, if there exists a polynomial p(n) such that the algorithm can solve any instance of size n in a time O(p(n)).

Problems requiring Ω(n 50) time to solve are essentially intractable for large n. Most known polynomial time algorithms run in time O(n^k) for a fairly low value of k.

The advantage in the class of polynomial-time algorithms is that all reasonable deterministic single processor models of computation can be simulated on each other with at most a polynomial slow-d.

**NP-Class**

The class NP consists of problems that are verifiable in polynomial time. NP is a class of decision problems for which it is easy to check the correctness of a given answer, with the aid of a little extra information. Hence, we are not asking for a way to find a solution, but only to verify that a solution really is correct.

Every problem in the given class can be solved in exponential time using exhaustive search.

**Example**

Consider an example to check if a problem is in P class or NP class

**Step 1** − If a problem is in class P, it is nothing but we can find a solution to that type of problem in polynomial time.

**Step 2** − If a problem is in class NP, it is nothing but that we can verify a possible solution in polynomial time.

**Step 3** − Consider another way, NP means that a problem is NondeterministicallyPolynomial. Specifically, that means that if you could build a machine that had the ability to try all the possible solutions of your problem at once, it could finish in polynomial time.

We know this to be true because we know that we can verify a possible solution in polynomial time, and what that machine is basically doing is trying to verify (test) all of the potential answers to the problem at the same time.

**Step 4** − So, if you can solve a problem in polynomial time, you can certainly verify that your answer is correct in polynomial time, can't you? Sure, if you can prove that your algorithm is correct and that it can find an answer in polynomial time, which it must to be in P.

Advertisements