CS计算机代考程序代写 AI algorithm ����������

����������
����
����
���

�����������

Variables i
shortest distance from s to V is dev

foreach f

X

y t

i

du deo w UN KEY.DEE
des o

i
objectivefunction i Minimised

to

c

1

Discussion 10

1. Given the SAT problem from lecture for a Boolean expression in Conjunctive Normal Form
with any number of clauses and any number of literals in each clause. For example,

(X1 � �X3) � (X1 � �X2 � X4 � X5) � …

Prove that SAT is polynomial time reducible to the 3-SAT problem (in which each clause
contains at most 3 literals.)

2. The Set Packing problem is as follows. We are given m sets S1, S2, … Sm and an integer k.
Our goal is to select k of the m sets such that no selected pair have any elements in common.
Prove that this problem is NP-complete.

3. The Steiner Tree problem is as follows. Given an undirected graph G=(V,E) with nonnegative
edge costs and whose vertices are partitioned into two sets, R and S, find a tree T ⊆ G such
that for every v in R, v is in T with total cost at most C. That is, the tree that contains every
vertex in R (and possibly some in S) with a total edge cost of at most C.
Prove that this problem is NP-complete.

Iii s
S F

ki L GF k

ta’s Extra.ua
nqvrz K VK.VN
MVNzVkz N VKzVK3
N Y R9VnzV DnEVKsVn
T 9

kiVNzVKzVR4VN5

ea mimm

SAT Sp3SAT

3 SAT SpSAT

R

o

O
la d

soothingsnot L

Discussion 11

1. In the Min-Cost Fast Path problem, we are given a directed graph G=(V,E) along with positive
integer times te and positive costs ce on each edge. The goal is to determine if there is a path P
from s to t such that the total time on the path is at most T and the total cost is at most C (both T
and C are parameters to the problem). Prove that this problem is NP-complete.

2. We saw in lecture that finding a Hamiltonian Cycle in a graph is NP-complete. Show that
finding a Hamiltonian Path — a path that isits each erte e actl once, and isn t req ired to
return to its starting point — is also NP-complete.

3. Some NP-complete problems are polynomial-time solvable on special types of graphs, such
as bipartite graphs. Others are still NP-complete.
Show that the problem of finding a Hamiltonian Cycle in a bipartite graph is still NP-complete.

I

A Shou HC problem in a bipartitegraph
is in NP

2 choose general HC problem

3 Show HC Sp HC in a bipartitegraph

G
G

i
Hc

O

B
A

013

no
G

o

G c C

A BCA AA’BBEDA
ABC Cc AA’BBC

A B’c A’Bc’A

C ABC C A A A’BB B’C

a

o

vertex Conn Ep Set cover

1 a

CE

nose
O

p Shon Ham Dath is i w P

z
Skip
Use HC

3 Show HC E p
H P

A 6 B AI 3

a
a

Kilo

B

i

Discussion 12

1. The bin packing problem is as follows. You have an infinite supply of bins, each of which can
hold M maximum weight. You also have n objects, each of which has a (possibly distinct)
weight wi (any given wi is at most M). Our goal is to partition the objects into bins, such that no
bin holds more than M total weight, and that we use as few bins as possible. This problem in
general is NP-hard.
Give a 2-approximation to the bin packing problem. That is, give an algorithm that will
compute a valid partitioning of objects into bins, such that no bin holds more than M weight, and
our algorithm uses at most twice as many bins as the optimal solution. Prove that the
approximation ratio of your algorithm is two.

2. Suppose you are given a set of positive integers A: a1 a2 … an and a positive integer B. A
subset S A is called feasible if the sum of the numbers in S does not exceed B.

The sum of the numbers in S will be called the total sum of S. You would like to select a feasible
subset S of A whose total sum is as large as possible.

Example: If A = {8, 2, 4} and B = 11 then the optimal solution is the subset S = {8, 2}.

Give a linear-time algorithm for this problem that finds a feasible set S A whose total sum is at

least half as large as the maximum total sum of any feasible set S’ A. Prove that your
algorithm achieves this guarantee.
You may assume that each ai < B. 3. A cargo plane can carry a maximum weight of 100 tons and a maximum volume of 60 cubic meters. There are three materials to be transported, and the cargo company may choose to carry any amount of each, up to the maximum available limits given below. Material 1 has density 2 tons/cubic meter, maximum available amount 40 cubic meters, and revenue $1,000 per cubic meter. Material 2 has density 1 ton/cubic meter, maximum available amount 30 cubic meters, and revenue $1,200 per cubic meter. Material 3 has density 3 tons/cubic meter, maximum available amount 20 cubic meters, and revenue $12,000 per cubic meter. Write a linear program that optimizes revenue within the constraints. You do not need to solve the linear program. 4. Recall the 0/1 knapsack problem: Input: n items, where item i has profit pi and weight wi, and knapsack size is W. Output: A subset of the items that maximizes profit such that the total weight of the set ≤ W. You may also assume that all pi 0, and 0 < wi ≤ W. We have created the following greedy approximation algorithm for 0/1 knapsack: Sort items according to decreasing pi/wi (breaking ties arbitrarily). While we can add more items to the knapsack, pick items in this order. Show that this approximation algorithm has no nonzero constant approximation ratio. In other words, if the value of the optimal solution is P*, prove that there is no constant (1 > > 0), where we can guarantee our greedy algorithm to achieve an approximate solution

with total profit P*.

items weight1 ProfitE
2 weightW Profit w

valueoftheopt so I W
valueof our approxSol 2

ratio of Iw
can be arbitrarily low

I U
Sort in decreasing order ofweight
place object in firstavailable bin

EEEheapproxinFF D 18,1 u

E

looking for a e5 approx

b B

r arr

B
what if ay does not fit

then remove all ao na s
and use art

Chie 3 e ae
a hi

2 M9 M2t3 M3 100 L
MY 40
M2 430
3p Fz M3 EGO

objectivefunction
Maximize 1,000Mt11,200M2 12,000M3

Background Decision version of
subsetseem for a set of a items
where item i has weight wi Is there

I t1I4uIag mq
Show Substsoan Ep MCFP

A
Ths
B An

off ato EI
S o r f a qotFEW c to turn
G B Bu

p t

Is there a path from stot

with art sW_ a
time

Quien

Before Lecture Notes – 15
Discussions 10-12