You are on page 1of 3

Michael Kaiser

Assignment 7
Comp 510
Fall 2012
23.1-1
Let (u, v) be a minimum-weight edge in a graph G. Show that (u, v) belongs to some minimum
spanning tree of G.
We can use Theorem 23.1 to prove this let ! " #$% &' (e a connecte)% un)irecte) graph *ith real+
value) *eights )e,ine) on &. -et A (e a su(set o, & #the empt. set in this case' that is inclu)e) in
some minimum+spanning+tree ,or !% an) let #/% $ 0 2' (e an. cut o, ! that respects A% an) let #u% v'
(e a light e)ge crossing #/% $ + /'. 1, / is an. set containing u (ut not v% an) the e)ge #u%v' is sa,e
,or A #(. this theorem'% then *e have proven that #u% v' (elongs to some minimum sapnning tree o,
!.
23.1-
Show that a graph has a uni!ue minimum spanning tree if, for ever" #ut of the graph, there is
a uni!ue light edge #rossing the #ut. Show that the #onverse is not true b" giving a
#ountere$ample.
Assume that ,or ever. cut o, !% there is a uni2ue light e)ge crossing the cut. Consi)er t*o
minimum+spanning+trees o, !% T an) T3. 1, *e remove an. e)ge #u%v' ,rom T% T (ecomes
)isconnecte)% resulting in a cut #/% $ 0 /'. We can prove that the e)ge #u%v' is a light e)ge crossing
the cut. Consi)er an e)ge #4%.' in T3 that crosses #/% $ 0 /'% an) it must also (e a light e)ge crossing
the cut. 5ecause the light e)ge crossing the cut is uni2ue% the e)ges #u%v' an) #4%.' must (e the
same. Thus% #u%v' is in T3% an) (ecause an. e)ge can (e selecte) as #u%v%'% *e have proven that T an)
T3 are the same% an) is an uni2ue minimum+spanning+tree o, !.
The converse is not true% consi)er this graph
#4'
6 7" 1
#.'
8 7" 1
#9'
1, given the cut #:.;% :4%9;'% (oth the e)ges #4%.' an) #.%9' *oul) generate a minimum+spanning+
tree.
23.2-1
%rus&al's algorithm #an return different spanning trees for the same input graph G,
depending on how ties are bro&en when the edges are sorted into order. Show that for ea#h
minimum spanning tree ( of G, there is a wa" to sort the edges of G in %rus&al's algorithm so
that the algorithm returns (.
To o(tain T ,rom Krus<al3s algorithm% *e simpl. sort the e)ges *ith the same *eights. &)ges o, the
same *eight shoul) have those e)ges *hich are in T selecte) over those that are not. This *ill result
in T (eing generate).
23.2-2
Suppose that the graph G ) (*, +) is represented as an ad,a#en#" matri$. Give a simple
implementation of -rim's algorithm for this #ase that runs in .(*
2
) time.
,or i " 1 to $
)ist=i> " in,init.?
pre)=i> " in,init.?
)ist=root> " 0?
Create min+priorit.+2ueue @ ,or in)e4es o, verticies (ase) on values o, )ist
*hile#@+Anot&mpt.'
i " @+A&BTCACT+M1D
,or#E " 1 to $'
i,#m=i>=E> " 1'
i, ##i is in @' FF #*eight#i%E' 7 )ist=E>''
pre)=E> " i?
)ist=E> " *eight#i%E'?
This is G#$
2
'% as .ou can )e)uce ,rom the ,or loops.
2/.1-1
0un the 1ellman-2ord algorithm on the dire#ted graph of 2igure 2/./, using verte$ 3 as the
sour#e. 4n ea#h pass, rela$ edges in the same order as in the figure, and show the d and 5
values after ea#h pass. 6ow, #hange the weight of edge (3, $) to / and run the algorithm again,
using s as the sour#e.
First run
4 s t 4 . 9
)H 2 5 I J 0
pH 9 4 . s source
/econ) run
4 s t 4 . 9
)H 0 2 2 7 +2
pH source 4 9 s t
Ko*ever% the secon) run has a negative *eight c.cle.
2/.1-3
Given a weighted, dire#ted graph G ) (*, +) with no negative-weight #"#les, let m be the
ma$imum over all pairs of verti#es u, v in * of the minimum number of edges in a shortest
path from u to v. (7ere, the shortest path is b" weight, not the number of edges.) Suggest
a simple #hange to the 1ellman-2ord algorithm that allows it to terminate in m 8 1 passes,
even if m is not &nown in advan#e.
To accomplish this% *e nee) to simpl. monitor changes
5&--MAD+FGCL#!% *% s'
1D1T+/1D!-&+/GMCC&#!% s'
change " true?
*hile#change "" true'
change " ,alse?
,or each e)ge#u%v' in !+A&
change " C&-AB#u% v% *'?
C&-AB#u%v%*'
i,#v.) A u.) N *#u%v''
v.) " u.) N *#u% v'?
v.pi " u?
change " true?
2/-2
9 d-dimensional bo$ with dimensions ($
1
, $
2
,..., $
d
) nests within another bo$ with dimensions
("
1
, "
2
,..., "
d
) if there e$ists a permutation 5 on :1, 2,..., d; su#h that $
5(1)
< "
1
, $
5(2)
< "
2
,..., $
5(d)
<
"
d
.
a. 9rgue that the nesting relation is transitive.
b. =es#ribe an effi#ient method to determine whether or not one d-dimensional bo$ nests
inside another.
#. Suppose that "ou are given a set of n d-dimensional bo$es :1
1
, 1
2
,..., 1
n
;. =es#ribe an
effi#ient algorithm to determine the longest se!uen#e (1
i1,
1
i2
, ....... 1
i&
) of bo$es su#h that
nests within 1
i ,81
for , ) 1, 2,..., & - 1. +$press the running time of "our algorithm in
terms of n and d.
a'
!iven a permutation O% i, 4
O#1'
7 .
1
% 4
O#2'
7 .
2
% ... an) so on% an) i, .
O#1'
7 9
1
% .
O#2'
7 9
2
% ... an) so on% *e
can )etermine that 4
O#1'
7 9
1
% 4
O#2'
79
2
% ... an) so on. There,ore #4
1
%4
2
%...%4
)
' nests *ithin #.
1%
.
2
%...%.
)
'%
an) #.
1%
.
2
%...%.
)
' nests *ithin #9
1%
9
2
%...%9
)
' is true an) transitive.
('
Ta<e the )imensions o, the (o4 an) sort them. Then iterate through each )imension an) ensure that
the )imensions o, the ,irst (o4 is al*a.s larger than the )imensions o, other. 1, this is ever not true%
then it is not possi(le to nest the secon) (o4 *ithin the ,irst.
c'
/ort the or)er o, the )imensions ,or all (o4es
/ort the (o4es in or)er o, si9e #compare each (o4 as per part 5'
For each (o4% loo< at this (o4 an) the ne4t (o4% i, it )oes not nest% *e e4clu)e the ,irst (o4% an)
continue.
We are then le,t *ith the longest se2uence o, (o4es *hich nest *ithin 5
iE
N1.
The running time ,or the sorting is G#ndln#d'' 0 2uic< or heap sort
The running time ,or the secon) sort is G#nlg#n'' 0 same
The runningtime ,or se2uencing through the (o4es is G#dn'.
Thus *e have G#n#dlgd N lg#n' N d' .
Ce,erences
Te4t(oo< an) solution manual
http88stu)ent.csuci.e)u8P)ouglas.holmes2538Assignment7.html

You might also like