0% found this document useful (1 vote)
16 views

NP Np-Hard Np-Complete: Data Structure and Algorithm

Uploaded by

javeria sohail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
16 views

NP Np-Hard Np-Complete: Data Structure and Algorithm

Uploaded by

javeria sohail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

NP NP-HARD

NP-COMPLETE
Data Structure And
Algorithm
Group 2:
• 2521311 Azka Muntazza
• 2521324 Munazza (Leader)
• 2521326 Zainab Shahid
• 2521332 Javeria Sohail
• 2521349 Tayyaba Khan

Add a footer 2
FR
Deterministic And Non-deterministic

Deterministic Algorithm Non-Deterministic Algorithm


• The algorithms in which the • the algorithms in which the
result of every algorithm is result of every algorithm is not
uniquely defined are known as uniquely defined and result
the Deterministic Algorithm. In could be random are known as
other words, we can say that the Non-Deterministic
the deterministic algorithm is Algorithm.
the algorithm that performs
fixed number of steps and
always get finished with an
accept or reject state with the
same result.
FR
P (Deterministic Algorithms)
• 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.
• Example: linear search, binary search, insertion
sort, merge sort.
FR
NP (Non-deterministic)
• The NP 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.
• Example:
• Non deterministic N search Algorithm
FR

Non deterministic N search The statement


Algorithm • Choice();
• Success();
{ j=choice(); • Failure();
If (key=A[j]) Are non deterministic
{ statement
write(j);
Success();
}
Write (0);
Failure ();}
This Class Contains Many Problems That One FR
Would Like To Be Able To Solve Effectively:
• Boolean Satisfiability Problem (SAT).
• Hamiltonian Path Problem.
• Graph colouring.
FR
SATISFIABILITY, SAT (base problem)
is the problem of determining if there exists an
interpretation that satisfies a given Boolean
formula.
The CNF-satisfiability problem is a version of the
Boolean satisfiability problem, where the Boolean
formula is specified in the conjunctive normal form
(CNF), i.e., a conjunction of clauses, where each
clause is a disjunction of literals, and a literal is a
variable or its negation.
To prove the relation between all exponential time
taking problem and taking one base problem
FR
Find At What Value Of X The CNF Is True
i

Xi ={x1,x2,x3}
CNF={x1 V x2 V x3} ∧ {x1 V x2 V x3}
FR
Exponential Time:
• Satisfiability-2n
• 0/1knap sack-2n
• Traveling sp-2n
• Sum of Subset-2n
• Graph coloring-2n
• Hamiltonion cycle-2n
FR
Reduction:
In computability theory and computational
complexity theory, a reduction is an
algorithm for transforming one problem
into another problem. A sufficiently efficient
reduction from one problem to another may be
used to show that the second problem is at
least as difficult as the first.
Satisfiability-2n ∝ 0/1knap sack-2n
Reduction converting time must be polynomial
time.
FR
NP-hard
An NP-hard problem is at least as hard as the
hardest problem in NP and it is the class of the
problems such that every problem in NP reduces to
NP-hard.
• Some of the examples of problems in Np-hard are:
• Halting problem.
• Qualified Boolean formulas.
• No Hamiltonian cycle.
FR
Satisfiability-2n ∝ 0/1knap Sack-2n

• Reduction has transitive property.


• A property is called transitive property, if x, y and z
are the three quantities, and if x is related to
y by some rule, and y is related to z by the
same rule, then we can say x is related to z by
the same rule.
• Let satisfiability is NP-hard than 0/1 knap sack
become NP-hard as reduction is occurring.
• If 0/1 knap sack reduce to Graph colouring than
Graph colouring become NP-hard.
FR
NP-complete
A problem is NP-complete if it is both NP and NP-
hard. NP-complete problems are the hard problems
in NP.
• Some example problems include:
• Decision version of 0/1 Knapsack.
• Hamiltonian Cycle.
• Satisfiability.
• Vertex cover.
FR
Let satisfiability is NP (having non-
deterministic algorithm) and also it is NP-
hard(as pervious) than satisfiability is NP-
complete asit reduced to 0/1 knap sack it also
become NP-complete as reduction is occurring.
FR
Conclusion:
FR

Add a footer 17
FR

Thank you

18

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy