Professional Documents
Culture Documents
Alg IntDecProb_NPC
Alg IntDecProb_NPC
Example:
Is the optimal profit of 0/1 knapsack >= v ???
Is the optimal cost of TSP <=D ???
Decision problems- DPm
Decision problems- DPm
• Decision problems can be further be classified
in:
• decidable, where we have a way to solve
them, or
• undecidable, for which there cannot be or has
not been yet discovered a way to solve them.
حتمية – احتمالية – كمية -غير حتمية
DPRm
• Theory developed in terms of yes/no
problems
Example:
– Independent set
• Given a graph G and an integer K; does G have an
independent set of size at least K?
– Vertex cover
• Given a graph G and an integer K, does the graph have
a vertex cover of size at most K?.
Deterministic and non-Deterministic
• Deterministic: if we can write a computer
program for a decision problem that is Y or N in a
finite time. The output of every problem is
defined uniquely.
• Non-deterministic
The outcome of each operation is not defined
uniquely, but restricted to a set of possibilities.
Can’t be executed on conventional machines ( االت
)تقليدية, but on hypothetical machines أجهزة افتراضية
based on the following steps/ points of guessing and
checking
steps/ points of guessing and checking:
1- choice(s): arbitrary chooses one of element of s.
2- failure: signals on unsuccessful completion
3. success: signals on successful completion
Example:
search a target x in unordered array A on n
elements
• Example: search a target x in unordered array A on n
elements
If (∑ xiwi<=M)
i=1->n
then success
else
failure
}
Class P and NP
P:yes/no NP: yes/no problem with a polynomial time checking
P: Polynomial; the set of all decision problems solvable by deterministic algorithm in polynomial time.
O(nk), k:const
That is; Class of problems that can be solved in polynomial time
A polynomial is an expression consisting of variables (like x) raised to non-negative integer powers
NP: set of all decision problems solvable by non-deterministic algorithms in polynomial time and also
verifiable in polynomial time.
• Problems solvable in non-deterministic polynomial time . . .
• Problems where “yes” instances have polynomial time checkable certificates
That is: if we were given somehow a solution (certificate), we could verify that certificate is correct in poly
time.
ie, Hamiltonian path:
Given a sequence <v1,v2,…,v|v|> of |V| vertices,
we can easily check in poly time that (vi, vi+1)ϵ E for =1,2,…, |v|-1 and (v|v|,v1) ϵ E as well.