You are on page 1of 2

The P in the P class stands for Polynomial Time.

It is the collection of decision problems(problems with a “yes” or “no” answer) that can be solved
by a deterministic machine in polynomial time. Features: The solution to P problems is easy to find, P is often a class of computational problems that
are solvable and tractable. Tractable means that the problems can be solved in theory as well as in practice. But the problems that can be solved in
theory but not in practice are known as intractable.

The NP in NP class stands for Non-deterministic Polynomial Time. It is the collection of decision problems that can be solved by a non-
deterministic machine in polynomial time. Features: The solutions of the NP class are hard to find since they are being solved by a non-deterministic
machine but the solutions are easy to verify, Problems of NP can be verified by a Turing machine in polynomial time.

A problem is NP-complete if it is both NP and NP-hard. NP-complete problems are the hard problems in NP. Features: NP-complete problems are
special as any problem in NP class can be transformed or reduced into NP-complete problems in polynomial time, If one could solve an NP-complete
problem in polynomial time, then one could also solve any NP problem in polynomial time.

An NP-hard problem is at least as hard as the hardest problem in NP and it is a class of problems such that every problem in NP reduces to NP-hard.
Features: All NP-hard problems are not in NP, It takes a long time to check them. This means if a solution for an NP-hard problem is given then it
takes a long time to check whether it is right or not, A problem A is in NP-hard if, for every problem L in NP, there exists a polynomial-time reduction
from L to A.

Deterministic Algorithm - A deterministic algorithm is one whose behavior is completely determined by its inputs and the sequence of its
instructions, Can solve the problem in polynomial time, Operation are uniquely defined, Deterministic algorithms usually have a well-defined worst-
case time complexity. Non-deterministic Algorithm - A non-deterministic algorithm is one in which the outcome cannot be predicted with certainty,
even if the inputs are known, For a particular input the computer will give different outputs on different execution, Can’t solve the problem in
polynomial time, Time complexity of non-deterministic algorithms is often described in terms of expected running time.

Tractable Problem: A problem that is solvable by a polynomial-time algorithm.The upper bound is polynomial. Examples - Searching an
unordered list, Searching an ordered list, Sorting a list, Multiplication of integers (even though there’s a gap), Finding a minimum spanning
tree in a graph (even though there’s a gap). Intractable Problem: a problem that cannot be solved by a polynomial-time algorithm. The
lower bound is exponential.
From a computational complexity stance, intractable problems are problems for which there exist no efficient algorithms to solve them.
Most intractable problems have an algorithm that provides a solution, and that algorithm is the brute-force search.
This algorithm, however, does not provide an efficient solution and is, therefore, not feasible for computation with anything more than the
smallest input. Example - 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. Cooks Theorum - states that the Boolean satisfiability problem is NP-complete. That
is, it is in NP, and any problem in NP can be reduced in polynomial time by a deterministic Turing machine to the Boolean satisfiability problem.
an SAT is one of the toughest problems, as there is no known algorithm other than the brute force approach. A brute force algorithm would be an
exponential-time algorithm. Cook demonstrated the reduction of other hard problems to SATs . 1-> Circuit- SAT: A circuit-SAT can be stated as
follows: given a Boolean circuit, which is a collection of gates such as AND, OR, and NOT, and n inputs, is there any input assignments of Boolean
variables so that the output of the given circuit is true? Again, the difficulty with these problems is that for n inputs to the circuit. 2n possible outputs
should be checked. Therefore, this brute force algorithm is an exponential algorithm and hence this is a hard problem. 2-> CNF-SAT: This problem is
a restricted problem of SAT, where the expression should be in a conjunctive normal form. An expression is said to be in a conjunction form if all the
clauses are connected by the Boolean AND operator. Like in case of a SAT, this is about assigning truth values to n variables such that the output of
the expression is true. 3-> 3-CNF-SAT(3-SAT): This problem is another variant where the additional restriction is that the expression is in a
conjunctive normal form and that every clause should contain exactly three literals. This problem is also about assigning n assignments of truth values
to n variables of the Boolean expression such that the output of the expression is true. In simple words, given an expression in 3-CNF, a 3-SAT
problem is to check whether the given expression is satisfiable. These problems can be used to prove the NP-completeness of some important
problems. || Standard NP-complete problems refer to a set of problems that are known to be NP-complete, meaning they belong to the
class of computational problems that are difficult to solve efficiently. NP-complete problems are a subset of the larger class called NP
(nondeterministic polynomial time). These problems have the property that if any one of them can be solved in polynomial time, then all NP
problems can be solved in polynomial time, making them challenging to solve in practice. Some examples of standard NP-complete
problems include: Boolean satisfiability problem (SAT): Given a Boolean formula, determine if there exists an assignment of truth values to
variables that makes the formula true. Traveling salesman problem (TSP): Given a list of cities and the distances between them, find the
shortest possible route that visits each city exactly once and returns to the starting city. Knapsack problem: Given a set of items with weights
and values, determine the most valuable combination of items that can be carried in a knapsack of limited capacity. Graph coloring
problem: Given an undirected graph, assign colors to its vertices in such a way that no two adjacent vertices have the same color and using
the minimum number of colors. Reduction techniques are used to prove the NP-completeness of new problems by reducing them to known
NP-complete problems. The idea is to demonstrate that if a known NP-complete problem can be solved efficiently, then the new problem
can also be solved efficiently. There are two commonly used reduction techniques: Cook-Levin reduction: This reduction is used to prove
the NP-completeness of problems in the Boolean satisfiability (SAT) family. It involves transforming an instance of an NP-complete problem
into an equivalent instance of the new problem. Polynomial-time reduction: This reduction is used to prove the NP-completeness of
problems outside the SAT family. It involves transforming an instance of an NP-complete problem into an instance of the new problem using
a polynomial-time computable function.

An approximation algorithm is a way of dealing with NP-completeness for an optimization problem. This technique does not guarantee the
best solution. The goal of the approximation algorithm is to come as close as possible to the optimal solution in polynomial time. Such
algorithms are called approximation algorithms or heuristic algorithms. Features - An approximation algorithm guarantees to run in
polynomial time though it does not guarantee the most effective solution. An approximation algorithm guarantees to seek out high accuracy
and top quality solution(say within 1% of optimum). Examples - In the vertex cover problem, the optimization problem is to find the
vertex cover with the fewest vertices, and the approximation problem is to find the vertex cover with few vertices. In the traveling
salesperson problem, the optimization problem is to find the shortest cycle, and the approximation problem is to find a short cycle. This is
an optimization problem that models many problems that require resources to be allocated. Here, a logarithmic approximation ratio is used.
In the Subset sum problem, the optimization problem is to find a subset of {x1,×2,×3…xn} whose sum is as large as possible but not larger
than the target value t. || A randomized algorithm is an algorithm that incorporates an element of randomness or probabilistic
choices during its execution. Unlike deterministic algorithms that always produce the same output for a given input, randomized
algorithms introduce randomness to achieve certain desirable properties such as efficiency, simplicity, or improved performance in
terms of time or space complexity. Example - Las Vegas Algorithms, Monte-Carlo algo. Randomized algorithms are useful in
various scenarios, including: Approximation: Randomized algorithms can provide approximate solutions for optimization problems
efficiently by leveraging random choices to find near-optimal solutions. They can provide guarantees on the quality of the
approximation achieved. Sampling: Randomized algorithms are commonly used for sampling tasks, such as selecting a random
subset from a larger set or generating random permutations. These algorithms enable efficient random sampling without
exhaustively examining all possibilities. Cryptography: Randomness is essential in cryptographic protocols and algorithms to ensure
security. Randomized algorithms are employed for tasks such as generating random keys or randomizing data to prevent
unauthorized access. Machine Learning: Randomized algorithms play a role in various aspects of machine learning, including
random initialization of model parameters, randomization in training algorithms, and random sampling for dataset preprocessing.
Randomized algorithms are particularly useful when dealing with large-scale problems, in situations where deterministic solutions
are impractical or computationally expensive. They provide a trade-off between guaranteed correctness and efficiency by leveraging
random choices and probabilities.

Beyond the classes of NP (nondeterministic polynomial time) and P (polynomial time), there exist more complex classes of
computational problems. Two such classes are known as PSPACE and EXPTIME, which are considered to be beyond NP in terms of
computational complexity. PSPACE (Polynomial Space): PSPACE is the class of decision problems that can be solved using a
polynomial amount of space on a deterministic Turing machine. It represents problems that can be solved in polynomial space
complexity, regardless of the time required for computation. PSPACE encompasses all problems in P and NP, as well as many other
complex problems. Examples of PSPACE-complete problems include Quantified Boolean Formulas (QBF) and Chess.
EXPTIME(Exponential Time): EXPTIME is the class of decision problems that can be solved using a deterministic Turing machine in
exponential time. It represents problems that can be solved within a fixed exponential time bound, regardless of the space used.
EXPTIME includes problems that grow rapidly in complexity and cannot be efficiently solved by algorithms that run in polynomial
time. The famous "Traveling Salesman Problem" (TSP) is an example of an EXPTIME-complete problem. These classes, PSPACE and
EXPTIME, demonstrate the increasing complexity of computational problems beyond the scope of polynomial time algorithms. They
highlight problems that are computationally challenging and often require exponential resources (either time or space) for their
solution. The Bin Packing algorithm is a combinatorial optimization algorithm that addresses the problem of efficiently packing a
set of objects into a minimum number of containers or bins. The goal is to minimize the number of bins used while ensuring that the
total size or weight of the objects packed into each bin does not exceed its capacity.The problem can be formulated as follows:
Given a set of items, each with a size or weight, and a fixed capacity for each bin, the objective is to find a packing arrangement that
minimizes the number of bins required. The items cannot be split or divided; they must be packed as whole units.The Bin Packing
problem is known to be NP-hard, which means there is no known polynomial-time algorithm that can solve it optimally for all
possible inputs. One of the popular algorithms for Bin Packing is the First Fit Decreasing (FFD) algorithm, which proceeds as follows:
Sort the items in non-increasing order of their sizes or weights, Initialize an empty bin, For each item in the sorted order, try
to place it in the first bin where it fits without exceeding the capacity. If no such bin exists, create a new bin and place the
item in it, Repeat step 3 for all items.

A network flow algorithm is an algorithm used to solve problems related to the flow of quantities through a network. In a network,
flow refers to the movement of some resource (such as water, goods, or data) from source nodes to sink nodes through
interconnected edges or arcs.The most well-known and widely used network flow algorithm is the Ford-Fulkerson algorithm. It
solves the maximum flow problem, which aims to determine the maximum amount of flow that can be sent from a source node to a

sink node in a given network. Algo- Initialize the flow in all the edges to 0 --
While there is an augmenting path between the source and the sink, add this path to the flow -- Update the residual graph .kxsxk sx

You might also like