Daa M-5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 95

Design and Analysis of Algorithms

Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Basic concepts,
– Assignment Problem,
– non-deterministic
– Travelling Sales
algorithms,
Person problem
– P, NP, NP-Complete,
and NP-Hard classes
2
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Basic concepts,
– Assignment Problem,
– non-deterministic
– Travelling Sales
algorithms,
Person problem
– P, NP, NP-Complete,
and NP-Hard classes
3
Backtracking
• Some problems can be solved, by exhaustive search.
• Backtracking is a more intelligent variation of
this approach.
• The principal idea is to construct solutions one
component at a time and evaluate such
partially constructed candidates as follows.
– If a partially constructed solution can be
developed, continue.
– If there is no legitimate option for the next
component, backtrack to replace the last
component of the partially constructed solution
with its next option.

4
Backtrackin
• State-space tree, g
represents the processing
• Its root represents an initial state
• The nodes of the first level in the tree represent
the choices made for the first component of a
solution
• The nodes of the second level represent the choices
for the second component, and so on.
• A node in a state-space tree is said to be promising
– if it corresponds to a partially constructed
solution that may still lead to a complete
solution;
– otherwise, it is called nonpromising.
• Leaves represent either nonpromising dead ends 5
Backtrackin
• In the majority ofgcases, a states-pace tree for a
backtracking algorithm is constructed in the
manner of depth-first search.
• If the algorithm reaches a complete solution to
the problem, it either stops (if just one solution is
required) or continues searching for other
possible solutions.

6
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Basic concepts,
– Assignment Problem,
– non-deterministic
– Travelling Sales
algorithms,
Person problem
– P, NP, NP-Complete,
and NP-Hard classes
7
N-Queens Problem
Problem Definition
• The problem is to place n queens on an n × n
chessboard so that no two queens attack each
other by being in the same row or in the same
column or on the same diagonal.

• So let us consider the 4-queens problem and solve it


by the backtracking technique.

8
4-Queens problem
• Since each of the four queens has to be placed in
its own row, all we need to do is to assign a
column for each queen on the board presented in
figure.

9
4-Queens problem
• The state-space tree
of this search is
shown in figure.

Note: This tree shows expansion of


nodes till it gets a solution. For multiple
solutions it need to be expanded further
10
4-queens problem
• If other solutions need to be found, the algorithm
can simply resume its operations at the leaf at
which it stopped.
• Alternatively, we can use the board’s symmetry
for this purpose.
• Finally, it should be pointed out that a single
solution to the n-queens problem for any n ≥ 4 can
be found in linear time.

11
N-queens prblem
Algorithm to find all solutions of n-queens problem

12
N-queens prblem

13
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Basic concepts,
– Assignment Problem,
– non-deterministic
– Travelling Sales
algorithms,
Person problem
– P, NP, NP-Complete,
and NP-Hard classes
14
Sum of Subsets Problem
Problem definition
• Find a subset of a given set A = {a1, . . . , an } of n
positive integers whose sum is equal to a given
positive integer d.
Example
• For A = {1, 2, 5, 6, 8} and d = 9, there are
two solutions: {1, 2, 6} and {1, 8}.
• Of course, some instances of this problem may
have no solutions.
• State space tree is shown in next slide

15
Sum of Subsets Problem
• It is convenient to sort the set’s elements in
increasing order.
• In the state space tree at a node, If sum is not equal to
d, we can terminate the node as non-promising if either
of the following two inequalities holds:

16
Sum of Subsets Problem
• State space tree

17
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Basic concepts,
– Assignment Problem,
– non-deterministic
– Travelling Sales
algorithms,
Person problem
– P, NP, NP-Complete,
and NP-Hard classes
18
Graph Coloring

19
Graph Coloring
• Problem Statement
– Given an undirected graph and a number m,
– determine if the graph can be colored with at most
m colors
– such that no two adjacent vertices of the graph are
colored with same color.
• Problem is also called as m-colorability
decision problem
• Here coloring of a graph means assignment of
colors to all vertices.

20
Graph Coloring
Applications
To make exam schedule for a university
• This problem can be represented as a graph
where every vertex is a subject and an edge
between two vertices mean there is a common
student.
• So this is a graph coloring problem where
minimum number of time slots is equal to the
chromatic number of the graph.

21
Graph Coloring
Applications
Mobile Radio Frequency Assignment
• When frequencies are assigned to towers,
frequencies assigned to all towers at the
same location must be different.
• How to assign frequencies with this constraint?
What is the minimum number of frequencies
needed?
• This problem is also an instance of graph coloring
problem where every tower represents a vertex
and an edge between two towers represents that
they are in range of each other.
22
Graph Coloring
Applications
Map Coloring
• Geographical maps of countries or states where
no two adjacent cities cannot be assigned same
color.
• Four colors are sufficient to color any map ( really?
)

23
Graph Coloring
• If the degree of the graph is d, it can be colored
with d+1 colors
• m-colorability optimization problem finds the
smallest integer m, for which the graph G can
be colored.
• This integer is referred as the chromatic number
of the graph.
• Example: 3 colors sufficient for the graph
given below

24
Graph
• coloring
Represent the graph by adjacency matrix G[1:n,1:n]
• Colors represented by 1,2,3 … m
• Solutions are given by n-tuple (x1,x2,….. Xn), xi is the
color of node i

25
k - Index of the
vertex to color
Algorithm
X[1:m] is initialized to zeros

26
X[ ] is initialized to zeros

Logic: For a vertex, start coloring from 1, if the


adjacent nodes have same color keep
incrementing till m.

The color of vertex


k & j are same

27
28
This state space tree shows all
the the successful coloring
(promising nodes leading to the
solution)

29
Analysis

m – degree of the graph

30
Problem
• Apply graph coloring algorithm for the graph
given below. Assume m=3

• Solve the same problem with m=4

31
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Basic concepts,
– Assignment Problem,
– non-deterministic
– Travelling Sales
algorithms,
Person problem
– P, NP, NP-Complete,
and NP-Hard classes
32
Hamiltonian cycle

33
Hamiltonian Cycle
• TSP tour is a Hamiltonian cycle.
• Here we discuss, Backtracking algorithm that finds
all distinct cycles
• Solution will be in the form (x1, x2, . . . . . , xn)

34
Hamiltonian Cycle

X[1:n] is initialized to zeros

35
36
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Basic concepts,
– Assignment Problem
– non-deterministic
– Travelling Sales
algorithms
Person problem
– P, NP, NP-Complete
& NP-Hard classes
37
Branch and Bound
• Backtracking - cut off a branch of the problem’s
state-space tree as soon as we can deduce that
it cannot lead to a solution
• This idea can be strengthened further if we deal
with an optimization problem.
• An optimization problem seeks to minimize
or maximize some objective function like
– a tour length – in TSP,
– the value of items selected – in knapsack
subject to some constraints.
• An optimal solution is a feasible solution with the
best value of the objective function
38
Branch and Bound
Compared to backtracking, branch-and-bound
requires two additional items:
1. a way to provide, for every node of a
state-space tree, a bound on the best value of
the objective function on any solution,
that can be obtained by adding further
components to the partially constructed solution
represented by the node
2. the value of the best solution seen so far

39
Branch and Bound
In general, we terminate a search path for any one
of the following three reasons:
1. The value of the node’s bound is not better than
the value of the best solution seen so far.
2. The node represents no feasible solutions because
the constraints of the problem are already
violated.
3. The subset of feasible solutions represented by
the node consists of a single point (and hence no
further choices can be made)

40
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Basic concepts,
– Assignment Problem
– non-deterministic
– Travelling Sales
algorithms
Person problem
– P, NP, NP-Complete
& NP-Hard classes
41
Assignment Problem
Problem Definition
• Assigning n people to n jobs so that the total cost
of the assignment is as small as possible.

• An instance of the assignment problem is


specified by an n × n cost matrix C
• We can state the problem as follows:
“select one element in each row of the matrix so
that no two selected elements are in the same
column and their sum is the smallest possible”

42
Example

• How can we find a lower bound on the cost of


an optimal selection without actually solving the
problem?

• We can do this by several methods.


– For example, optimal solution cannot be smaller
than the sum of the smallest elements in each of
the matrix’s rows.
– For the instance here, this sum is 2 + 3+ 1+ 4 = 10.
43
Figure: Lower bound computation

Note: Avoid the assigned jobs column for computation of lb, as it is not feasible

44
• Rather than generating a single child of the last
promising node as we did in backtracking, we will
generate all the children of the most promising
node among non-terminated leaves in the current
tree.
• How can we tell which of the nodes is most promising?
– We can do this by comparing the lower bounds
of the live nodes.
– It is sensible to consider a node with the best
bound as most promising (as of now)
• This variation of the strategy is called the
best-first branch-and-bound.

45
Note: After Computation of 9th Node, We have to explore nodes that have better lb than 13.
In this example we do not have such nodes. So we stop at 9.
46
Note: After Computation of 9th Node, We have to explore nodes that have better lb than 13.
In this example we do not have such nodes. So we stop at 9.
47
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Basic concepts,
– Assignment Problem
– non-deterministic
– Travelling Sales
algorithms
Person problem
– P, NP, NP-Complete
& NP-Hard classes
48
Branch & Bound -
• We will beTSP
able to apply the branch-and-bound
technique to instances of the TSP if we come up with
a reasonable lower bound on tour lengths.
• One very simple lower bound can be obtained by
finding the smallest element in the intercity distance
matrix D and multiplying it by the number of cities n.
• But there is a less obvious and more informative
lower bound for instances with symmetric matrix D
• For each city i, 1≤ i ≤ n,
– Find si – sum of the distances from city i to the 2
nearest cities;
– compute s, the sum of si i=1..n, divide the result by 2
49
Branch & Bound – TSP -
Example

50
Branch & Bound -
To reduce TSP
the amount of potential work, we
take advantage of two observations.
1. First, without loss of generality, we can consider
only tours that start at a.
2. Second, because our graph is undirected, we
can generate only tours in which b is visited
before c. (Why?)

51
TSP
3. In addition, after visiting n−1= 4 cities, a tour has
no choice but to visit the remaining unvisited city
and return to the starting one
• The state-space tree tracing the
algorithm’s application is given in Figure

52
53
54
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Assignment Problem – Basic concepts,
– Travelling Sales – non-deterministic
Person problem algorithms
– P, NP, NP-Complete
& NP-Hard classes
55
0/1 Knapsack problem
• Branch and Solution to 0/1 Knapsack problem

Problem Definition
• Given n items of known weights wi and values vi , i =
1, 2, . . . , n, and a knapsack of capacity W, find the
most valuable subset of the items that fit in the
knapsack.

56
0/1 Knapsack problem
• It is convenient to order the items of a given
instance in descending order by their
value-to-weight ratios.

• Each node on the ith level of this tree, 0 ≤ i ≤ n,


represents all the subsets of n items that include
a particular selection made from the first i
ordered items
• We record the total weight w and the total value v
of this selection in the node, along with some upper
bound ub

57
How to compute the upper
• bound?
A simple way to compute the upper bound ub is to
– add to v, the total value of the items
already selected,
– the product of the remaining capacity of the
knapsack W − w and the best per unit payoff
among the remaining items, which is vi+1/wi+1

ub = v + (W − w)(vi+1/wi+1).

58
Example
• Consider the following problem.
• The items are already ordered in descending order
of their value-to-weight ratios.

• Let us apply the branch-and-bound algorithm.

59
60
61
Discussion
• Solving the knapsack problem by a
branch-and-bound algorithm has a rather unusual
characteristic.
• For the knapsack problem, every node of the tree
represents a subset, and also a feasible solution of the
items given.
• We can use this fact to update the information about the
best subset seen so far after generating each new node in
the tree.
• If we had done this for the instance investigated above,
we could have terminated nodes 2 and 6 before node 8
was generated because they both are inferior to the
subset of value 65 of node 5.
62
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Assignment Problem – Basic concepts,
– Travelling Sales – non-deterministic
Person problem algorithms
– P, NP, NP-Complete
& NP-Hard classes
63
Some
• Live node Terminologies
- a node which has been generated and
all of whose children are not yet been generated.
• E-node - is a live node whose children are currently
being explored. In other words, an E-node is a
node currently being expanded.
• Dead node - a node that is either not to be
expanded further, or for which all of its children
have been generated
• Bounding Function - will be used to kill live
nodes without generating all their children.

64
Some
• Terminologies
Backtracking - is depth first node generation
with bounding functions.
• Branch-And-Bound is a method in which E-node
remains E-node until it is dead.
• Breadth-First-Search: Branch-and Bound with each
new node placed in a queue. The front of the
queen becomes the new E-node.
• Depth-Search (D-Search): New nodes are placed
in to a stack. The last node added is the first to be
explored.

65
Some Basic Concepts

The technique discussed here is applicable for minimization problems

66
0/1 Knapsack - B&B based solution
• The technique discussed here is applicable
for minimization problems
• So convert the knapsack problem (maximizing
the profit) into minimization problem by
negating the objective function

• Define cost

67
0/1 Knapsack - B&B based solution
Lower bound Upper bound

68
LCBB - Least Cost Branch &Bound solution

Example

Similar to the
Nodes with
computation
ෙ◌ා -22
of fractional least 𝒄
knapsack is
expanded

Note: Data is assumed to be sorted in p/w order

69
Computation method

• Node1 – Not a solution node, becomes


E-node, expanded, 2 & 3 generated &
added to list (Min heap wrt u) of live
nodes. (Minheap: 2,3) -22
• Node2 - is next E-node. Expanded, 4 & 5
generated. Added to list of live nodes.
(Minheap: 3,4,5)
• Next E node is 4. Expanded, 6 & 7 are
generated. Added to list of live
nodes. Minheap: 3,5,6,7
• Next E node: 6 or 7. Say expand 7. Nodes
8 & 9 generated. 8 is solution. Kill 9 as
ෙ◌ා
𝒄
> upper(-38).
ෙ◌ා
• Delete 3,5,6 as 𝒄 (E) > upper Lower bound
• Node 8 is the solution Upper bound
70
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Assignment Problem – Basic concepts,
– Travelling Sales – non-deterministic
Person problem algorithms
– P, NP, NP-Complete
& NP-Hard classes
71
FIFO Branch & Bound solution
• Example

Lower bound
Upper bound
72
Outline
• Backtracking • 0/1 Knapsack problem
– General method – LC Branch and Bound
– N-Queens problem solution
– Sum of subsets problem – FIFO Branch and
– Graph coloring Bound solution
– Hamiltonian cycles • NP-Complete and NP-
• Branch and Bound Hard problems
– Assignment Problem – Basic concepts,
– non-deterministic
– Travelling Sales Person lem algorithms
prob
– P, NP, NP-Complete
& NP-Hard classes
• ` 73
Basic Concepts
• For many of the problems we know and study, the
best algorithms for their solution have computing
times can be clustered into two groups;
– Solutions are bounded by the polynomial- Examples
include Binary search O(log n), Linear search O(n) or in
general O(nk) where k is a constant.
– Solutions are bounded by a non-polynomial -
Examples include travelling salesman problem
O(n22n) & knapsack problem O(2n/2).
As the time increases exponentially, even
moderate size problems cannot be solved.

74
Basic Concepts
• So far, no one has been able to device an
algorithm which is bounded by the polynomial for
the problems belonging to the non-polynomial.

• However impossibility of such an algorithm is


not proved.

75
Non deterministic
• algorithms
We also need the idea of two models of
computer (Turing machine): deterministic and
non- deterministic.

• A deterministic computer is the regular computer


we always thinking of.
• When the result of every operation is uniquely
defined then it is called deterministic
algorithm.

• A non-deterministic computer is one that is just like


we’re used to except that it has unlimited
parallelism, so that any time you come to a branch,
76
Non deterministic
• algorithms
When the outcome is not uniquely defined but is
limited to a specific set of possibilities, we call it
non deterministic algorithm.

77
Decision vs Optimization algorithms
• An optimization problem tries to find an
optimal solution.
• A decision problem tries to answer a
yes/no question.
• Most of the problems can be specified in
decision and optimization versions.
• For example, TSP can be stated as two ways
– Optimization - find hamiltonian cycle of
minimum weight
– Decision - is there a hamiltonian cycle of weight

k? 81
Decision vs Optimization algorithms
• For graph coloring problem,
– Optimization – find the minimum number of
colors needed to color the vertices of a graph so
that no two adjacent vertices are colored the
same color
– Decision - whether there exists such a coloring of
the graph’s vertices with no more than m colors?

• Many optimization problems can be recast in to


decision problems with the property that,
– the decision algorithm can be solved in
polynomial time if and only if the corresponding
82
P, NP
• NP stands for Non-deterministic Polynomial time.
• Definition: P is a set of all decision problems
solvable by a deterministic algorithm in polynomial
time.
• Definition: NP is the set of all decision
problems solvable by a nondeterministic
algorithm in polynomial time.

• This also implies P ⊆ NP


• i.e. Problems known to be in P are trivially in NP
83
P
• P is a complexity class that represents the set of all
decision problems that can be solved in polynomial
time.
• That is, given an instance of the problem, the answer
yes or no can be decided in polynomial time.
• Example
– Given a connected graph G, can its vertices be coloured
using two colours so that no edge is monochromatic?
– Algorithm: start with an arbitrary vertex, color it red and
all of its neighbours blue and continue. Stop when you run
out of vertices or you are forced to make an edge have
both of its endpoints be the same color.
Source:
Stackoverflow.com
84
NP
• NP is a complexity class that represents the set of all
decision problems for which the instances where
the answer is "yes" have proofs that can be verified
in polynomial time.
• This means that if someone gives us an instance of the
problem and a certificate (sometimes called a witness)
to the answer being yes, we can check that it is correct
in polynomial time.

Source:
Stackoverflow.com
85
NP - Example
Integer factorisation is in NP.
• This is the problem that given integers n and m, is
there an integer f with 1 < f < m, such that f divides n (f
is a small factor of n)?
• This is a decision problem because the answers are yes
or no.
• If someone hands us an instance of the problem (so they
hand us integers n and m) and an integer f with 1 < f <
m, and claim that f is a factor of n (the certificate), we
can check the answer in polynomial time by performing
the division n / f.

86
P,
• NP which are known to
But there are some problems
be in NP but don’t know if they’re in P.
• The example is the decision-problem version of
the Travelling Salesman Problem (decision-TSP).
• It’s not known whether decision-TSP is in P:
– there’s no known poly-time solution,
– but there’s no proof such a solution doesn’t exist.

• The most famous unsolved problem in


computer science is “whether P=NP or P≠NP? ”

87
NP-Complet
e
Reducible Problems
• Given decision problems P and Q, if an algorithm can
transform a solution for P into a solution for Q in
polynomial time, it’s said that Q is poly-time
reducible (or just reducible) to P.

Definition: NP-Complete
A decision problem D is said to be NP-complete if:
1. it belongs to class NP
2. every problem in NP is polynomially reducible to D

88
NP-Complet
• NP-Complete is ae
complexity class which represents the
set of all problems X in NP for which it is possible to
reduce any other NP problem Y to X in polynomial
time.

• Intuitively this means that we can solve Y quickly if


we know how to solve X quickly.
• Precisely, Y is reducible to X, if there is a polynomial
time algorithm f to transform instances y of Y to
instances x = f(y) of X in polynomial time, with the
property that the answer to y is yes, if and only if the
answer to f(y) is yes.
Source:
Stackoverflow.com
89
NP Complete
• Informally, these are the hardest problems in the
class NP
• If any NP-complete problem can be solved by
a polynomial time deterministic algorithm,
– then every problem in NP can be solved by a
polynomial time deterministic algorithm

• But Till date, no polynomial time


deterministic algorithm is known to solve any
of them

90
NP-Complet
• e
Example for NP-complete is
CNF-satisfiability problem.
• The CNF-satisfiability problem deals with
boolean expressions.
• This is given by Cook in 1971.
• The CNF-satisfiability problem asks whether or not
one can assign values true and false to variables of a
given boolean expression in its CNF form to make
the entire expression true.

91
Example for
• NP-Complete
Traveling salesman problem
• Hamiltonian cycle problem
• Clique problem
• Subset sum problem
• Boolean satisfiability problem
• Many thousands of other important
computational problems in computer science,
mathematics, economics, manufacturing,
communications, etc.

92
NP-Hard Problems
• These problems need not have any bound on
their running time.
• If any NP-Complete Problem is polynomial time
reducible to a problem X, that problem X
belongs to NP-Hard class.
• All NP-Complete problems are also NP-Hard.
• In other words if a NP-Hard problem is non-
deterministic polynomial time solvable, it is a
NP- Complete problem.
• Example of a NP problem that is not NPC is
Halting Problem.

93
NP-Hard Problems

Figure: Commonly believed relationship between


P, NP, NP-Complete and NP-hard problems

94
NP-Hard Problems
• If a NP-Hard problem can be solved in
polynomial time then all NP-Complete can be
solved in polynomial time.
• “All NP-Complete problems are NP-Hard but not
all NP-Hard problems are not NP-Complete.”
• NP-Complete problems are subclass of NP-Hard
• The more conventional optimization version of TSP
for finding the shortest route is NP-hard, not
strictly NP-complete.

95
NP-Hard
• Intuitively, these are the problems that are at least as hard
as the NP-complete problems.
• Note that NP-hard problems do not have to be in NP, and
they
do not have to be decision problems.
• The precise definition here is that a problem X is NP-hard, if
there is an NP-complete problem Y, such that Y is reducible
to X in polynomial time.

• But since any NP-complete problem can be reduced to any


other NP-complete problem in polynomial time, all NP-
complete problems can be reduced to any NP-hard problem
in polynomial time.
• Then, if there is a solution to one NP-hard problem in
96
NP-Hard
• Example: The halting problem is an NP-hard problem.
• This is the problem that given a program P and input I,
will it halt? This is a decision problem but it is not in NP.
It is clear that any NP-complete problem can be reduced
to this one. As another example, any NP-complete
problem is NP-hard.

Source:
Stackoverflow.com
97
98

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