Tractible Complexity Classes
Tractible Complexity Classes
Intractable Problem:
Examples
Towers of Hanoi: we can prove that any algorithm that solves this problem must have a worst-
case running time that is at least 2n − 1.
* List all permutations (all possible orderings) of n numbers.
Computability of Algorithms
A given computational problem is said to be computable if there exists an algorithm that can
solve a problem in an effective manner. Many problems (or functions) that are computable (or
decidable), meaning there exists some algorithm that computes an answer (or output) to any
instance of the problem (or for any input to the function) in a finite number of simple steps. A
simple example is the integer increment operation:
f(x) = x + 1
It should be intuitive that given any integer x, we can compute x + 1 in a finite number of
steps. Since x is finite, it may be represented by a finite string of digits.
Some Examples On Computable Problems –
These are simple examples of computable problem:
1. Computing the greatest common divisor of a pair of integers.
2. Computing the least common multiple of a pair of integers.
3. Finding the shortest path between a pair of nodes in a finite graph.
Definition of Decision Based Problem: - There are many problems for which the answer is a
Yes or a No. These types of problems are known as decision problems. For example,
Whether a given graph can be colored by only 4-colors.
Finding Hamiltonian cycle in a graph is not a decision problem, whereas checking a
graph is Hamiltonian or not is a decision problem.
A problem is called a decision problem if its output is a simple "yes" or "no" (or you may need
this of this as true/false, 0/1, accept/reject.) We will phrase many optimization problems as
decision problems. For example, Greedy method, D.P., given a graph G= (V, E) if there exists
any Hamiltonian cycle.
Non-computable Problems
Yet there are also problems and functions that that are non-computable (or undecidable or
uncomputable), meaning that there exists no algorithm that can compute an answer or output
for all inputs in a finite number of simple steps. (Undecidable simply means non-computable in
the context of a decision problem, whose answer (or output) is either “true” or “false”).
Example of an uncomputable problem is: determining whether a computer program loops
forever on some input (Infinite Loop).
In Computer Science, many problems are solved where the objective is to maximize or
minimize some values, whereas in other problems we try to find whether there is a solution or
not. Hence, the problems can be categorized as follows −
Optimization Problem
Optimization problems are those for which the objective is to maximize or minimize some
values. For example,
Finding the minimum number of colors needed to color a given graph.
Finding the shortest path between two vertices in a graph.
Complexity Classes
Definition of Polynomial time: - If we produce an output according to the given input within a
specific amount of time such as within a minute, hours. This is known as Polynomial time.
Definition of Non-Polynomial time: - If we produce an output according to the given input but
there are no time constraints is known as Non-Polynomial time. But yes output will produce but
time is not fixed yet.
Algorithms such as Matrix Chain Multiplication, Single Source Shortest Path, All Pair Shortest
Path, Minimum Spanning Tree, etc. run in polynomial time. However there are many problems,
such as traveling salesperson, optimal graph coloring, Hamiltonian cycles, finding the longest
path in a graph, and satisfying a Boolean formula, for which no polynomial time algorithms is
known. These problems belong to an interesting class of problems, called the NP-
Complete problems, whose status is unknown.
Definition of P class Problem: - The set of decision-based problems come into the division of
P Problems who can be solved or produced an output within polynomial time. P problems are
being easy to solve. These problems are called tractable, while others are called intractable or
superpolynomial.
Formally, an algorithm is 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)).
Definition of NP class Problem: - The set of all decision-based problems came into the
division of NP Problems who can't be solved or produced an output within polynomial time but
verified in the polynomial time. NP class contains P class as a subset. NP problems being hard
to solve. NP is the class of decision problems for which it is easy to check the correctness of a
claimed answer, with the aid of a little extra information. Hence, we aren’t asking for a way to
find a solution, but only to verify that an alleged solution really is correct.
The class NP consists of those problems that are verifiable in polynomial time.
Every problem in this class can be solved in exponential time using exhaustive search.
Note: - The term "NP" does not mean "not polynomial." Originally, the term meant "non-
deterministic polynomial. It means according to the one input number of output will be
produced.
Definition of NP-hard class: - Here you to satisfy the following points to come into the division
of NP-hard
1. If we can solve this problem in polynomial time, then we can solve all NP problems in
polynomial time
2. If you convert the issue into one form to another form within the polynomial time
1. It is in NP
2. It is NP-hard
P
versus NP
Every decision problem that is solvable by
a deterministic polynomial time algorithm is also solvable by a polynomial time non-
deterministic algorithm.
All problems in P can be solved with polynomial time algorithms, whereas all problems in NP -
P are intractable.
It is not known whether P = NP. However, many problems are known in NP with the property
that if they belong to P, then it can be proved that P = NP.
If P ≠ NP, there are problems in NP that are neither in P nor in NP-Complete.
The problem belongs to class P if it’s easy to find a solution for the problem. The problem
belongs to NP, if it’s easy to check a solution that may have been very tedious to find.
P PROBLEMS NP PROBLEMS
P problems are set of problems which can be NP problems are the problems which can be
solved in polynomial time by deterministic solved in non-deterministic polynomial
algorithms. time.