14 Notes
14 Notes
| Complexity Classes
Last Updated : 03 Oct, 2023
In computer science, there exist some problems whose solutions are not
yet found, the problems are divided into classes known as Complexity
Classes. In complexity theory, a Complexity Class is a set of problems
with related complexity. These classes help scientists to group problems
based on how much time and space they require to solve problems and
verify the solutions. It is the branch of the theory of computation that deals
with the resources required to solve a problem.
The common resources are time and space, meaning how much time the
algorithm takes to solve a problem and the corresponding memory usage.
The time complexity of an algorithm is used to describe the number of
steps required to solve a problem, but it can also be used to describe
how long it takes to verify the answer.
The space complexity of an algorithm describes how much memory is
required for the algorithm to operate.
Complexity classes are useful in organising similar types of problems.
What is NP problems?
Nondeterministic polynomial-time problems, commonly
known as NP problems. These problems have the special
property that, once a potential solution is provided, its
correctness can be verified quickly. However, finding the solution
itself may be computationally difficult.
Example: A well-known example of NP problems is prime
factorization. We can verify a factor of an integer in polynomial
time. However, we don’t know any polynomial time algorithm to
factorize a given integer.
Key characteristics of NP problems:
Characteristic Description
Efficient verification,
Efficiently solvable in
solution may not be found
polynomial time.
Solvability efficiently.
Efficient verification
algorithms are known, but
Polynomial time
efficient solution
algorithms are known.
algorithms are not
Time Complexity guaranteed.
It is unknown whether NP
P is a subset of NP. is a proper subset of P or if
Known Relationship they are equal.
Traveling
Sorting, searching,
Salesman, Boolean
shortest path problems.
Example Satisfiability.
Related Articles:
Introduction to NP-Complete Complexity
Classes
Last Updated : 15 May, 2024
Features of NP-Hard:
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, it takes a long time to check
whether it is right.
A problem ‘P’ is NP-hard if there is a polynomial-time reduction
from ‘Q’ to ‘P’ for every problem ‘Q’ in NP.
Real-World Applications:
Approximate Computing: In approximate computing, the
goal is to trade off accuracy for computational efficiency. Many
optimization problems in this domain, like optimizing
approximation algorithms, can be NP-hard. This implies that
finding optimal solutions might be impractical, and researchers
need to devise heuristic or approximation methods to get
close-to-optimal results.
Cryptography: While most cryptographic algorithms involve
polynomial-time operations, certain cryptographic problems,
such as solving certain lattice-based problems in post-quantum
cryptography, are believed to be NP-hard. This is crucial for
ensuring the security of cryptographic systems.
Data Mining: NP-hard problems often arise in data mining
tasks like clustering, feature selection, and association rule
mining. As data mining involves finding patterns and
relationships in large datasets, it’s common to encounter
optimization problems that are difficult to solve exactly.
Routing/Vehicle Routing: Routing problems, like finding the
shortest path or optimizing routes for vehicles, are often NP-
hard. These problems arise in logistics, transportation, and
networking. Practical solutions involve approximation
algorithms and heuristics due to the complexity of real-world
scenarios.
Problems under NP-Hard Class:
Traveling Salesman Problem (TSP)
Subset Sum problem
Knapsack Problem
Boolean Satisfiability Problem (SAT)
Graph Coloring Problem
Independent Set Problem
3-SAT Problem
Vertex Cover Problem
Bin Packing Problem
Hamiltonian Cycle Problem
Partition Problem
Knights Tour Problem
Quadratic Assignment Problem
Clique Problem
Difference between NP hard and NP
complete problem
Last Updated : 05 Jan, 2023
Prerequisite: NP-Completeness
NP Problem:
The NP problems set of problems whose solutions are hard to find
but easy to verify and are solved by Non-Deterministic Machine in
polynomial time.
NP-Hard Problem:
A Problem X is NP-Hard if there is an NP-Complete problem Y,
such that Y is reducible to X in polynomial time. NP-Hard problems
are as hard as NP-Complete problems. NP-Hard Problem need not
be in NP class.
If every problem of NP can be polynomial time reduced to it called
as NP Hard.
A lot of times takes the particular problem solve and reducing
different problems.
example :
1. Hamiltonian cycle .
2. optimization problem .
3. Shortest path
NP-Complete Problem:
A problem X is NP-Complete if there is an NP problem Y, such that
Y is reducible to X in polynomial time. NP-Complete problems are
as hard as NP problems. A problem is NP-Complete if it is a part of
both NP and NP-Hard Problem. A non-deterministic Turing
machine can solve NP-Complete problem in polynomial time.
A problem is np-complete when it is both np and np hard
combines together.
this means np complete problems can be verified in polynomial
time.
Example:
1. Decision problems.
2. Regular graphs.
Difference between NP-Hard and NP-Complete:
NP-hard NP-Complete
To solve this problem, it do not have To solve this problem, it must be both NP
to be in NP . and NP-hard problems.