You are on page 1of 5

5/1/2015

Coursera

FeedbackProblemSet#2

HelpCenter

YousubmittedthisquizonThu30Apr20158:53PMPDT.Yougotascoreof
4.00outof5.00.Youcanattemptagain,ifyou'dlike.

Question1
SupposewearegivenadirectedgraphG = (V , E)inwhicheveryedgehasadistinctpositive
edgeweight.Adirectedgraphisacyclicifithasnodirectedcycle.Supposethatwewantto
computethemaximumweightacyclicsubgraphofG (wheretheweightofasubgraphisthesum
ofitsedges'weights).AssumethatG isweaklyconnected,meaningthatthereisnocutwithno
edgescrossingitineitherdirection.

HereisananalogofPrim'salgorithmfordirectedgraphs.Startfromanarbitraryvertexs,
initializeS

andF

= {s}

.WhileS

endpointinSandoneendpointinV

,findthemaximumweightedge(u, v)withone

.AddthisedgetoF ,andaddtheappropriateendpoint

toS.
HereisananalogofKruskal'salgorithm.Sorttheedgesfromhighesttolowestweight.Initialize
.Scanthroughtheedgesateachiteration,addthecurrentedgeitoF ifandonlyifit

F =

doesnotcreateadirectedcycle.Whichofthefollowingistrue?

YourAnswer

Score

Explanation

0.00

ThemodificationofPrim'salgorithmoutputsa
subgraphwithn 1 edges,wheren isthenumberof

Bothalgorithms
alwayscomputea
maximumweightacyclic
subgraph.
Bothalgorithmsmight
failtocomputea
maximumweightacyclic
subgraph.
Onlythemodification
ofPrim'salgorithm

alwayscomputesa
https://class.coursera.org/algo2004/quiz/feedback?submission_id=102012

vertices.Doesthemaximumweightacyclicsubgraph
1/5

5/1/2015

Coursera

maximumweightacyclic

alwayshavethisproperty?

subgraph.
Onlythemodification
ofKruskal'salgorithm
alwayscomputesa
maximumweightacyclic
subgraph.
Total

0.00/
1.00

Question2
ConsideraconnectedundirectedgraphG withedgecoststhatarenotnecessarilydistinct.

Supposewereplaceeachedgecostc e byc e callthisnewgraphG .Considerrunningeither

Kruskal'sorPrim'sminimumspanningtreealgorithmonG ,withtiesbetweenedgecosts
brokenarbitrarily,andpossiblydifferently,ineachalgorithm.Whichofthefollowingistrue?
YourAnswer

Score

Explanation

1.00

Differenttiebreakingrules

Bothalgorithmscomputethesame
maximumcostspanningtreeofG .
Prim'salgorithmcomputesamaximum
costspanningtreeofG butKruskal's
algorithmmightnot.
Kruskal'salgorithmcomputesa
maximumcostspanningtreeofG but
Prim'salgorithmmightnot.
Bothalgorithmscomputeamaximum

costspanningtreeofG ,buttheymight
computedifferentones.
Total

https://class.coursera.org/algo2004/quiz/feedback?submission_id=102012

generallyyielddifferentspanning
trees.
1.00/
1.00

2/5

5/1/2015

Coursera

Question3
Considerthefollowingalgorithmthatattemptstocomputeaminimumspanningtreeofa
connectedundirectedgraphG withdistinctedgecosts.First,sorttheedgesindecreasingcost
order(i.e.,theoppositeofKruskal'salgorithm).InitializeT tobealledgesofG .Scanthrough
theedges(inthesortedorder),andremovethecurrentedgefromT ifandonlyifitliesona
cycleofT .

Whichofthefollowingstatementsistrue?

Your

Score

Explanation

1.00

Duringtheiterationinwhichanedgeisremoved,itwasonacycle
C ofT .Bythesortedordering,itmustbethemaximumcost
edgeofC .Byanexchangeargument,itcannotbeamemberof
anyminimumspanningtree.Sinceeveryedgedeletedbythe

Answer
The
algorithm
always
outputsa
minimum
spanning
tree.

algorithmbelongstonoMST,anditsoutputisaspanningtree(no
cyclesbyconstruction,connectedbytheLonelyCutCorollary),its
outputmustbethe(unique)MST.

The
algorithm
always
outputsa
spanning
tree,butit
mightnot
bea
minimum
cost
spanning
tree.
The
outputof
the
algorithm
willnever
havea
cycle,butit
mightnot
be
https://class.coursera.org/algo2004/quiz/feedback?submission_id=102012

3/5

5/1/2015

Coursera

connected.
The
outputof
the
algorithm
willalways
be
connected,
butitmight
have
cycles.
Total

1.00/
1.00

Question4
Consideranalphabetwithfiveletters,{a, b, c, d, e} ,andsupposeweknowthefrequencies
f a = 0.32

,f b

= 0.25

,f c

= 0.2 f d = 0.18

,andf e

= 0.05

.Whatistheexpectednumberof

bitsusedbyHuffman'scodingschemetoencodea1000letterdocument?
YourAnswer

Score

Explanation

1.00

Forexample,a = 00,b = 01 ,c = 10 ,d = 110 ,e = 111 .

2400
2230

3000
3450
Total

1.00/1.00

Question5
WhichofthefollowingstatementsholdsforHuffman'scodingscheme?

https://class.coursera.org/algo2004/quiz/feedback?submission_id=102012

4/5

5/1/2015

Coursera

YourAnswer

Score

Explanation

1.00

Suchaletterwillendureamergeinatleasttwoiterations:the
lastone(whichinvolvesallletters),andatleastoneprevious

Ifaletter's
frequencyis
atleast0.4 ,
thentheletter
willcertainly
becodedwith
onlyonebit.
Aletterwith
frequencyat
least0.5
mightget
encodedwith
twoormore
bits.
Ifthemost
frequentletter

hasfrequency
lessthan

iteration.Inthepenultimateiteration,iftheletterhasnotyet
enduredamerge,atleastoneofthetwootherremaining

,thenall
letterswillbe

subtreeshascumulativefrequencyatleast(1 .33)/2 > .33 ,


sotheletterwillgetmergedinthisiteration.

0.33

codedwithat
leasttwobits.
Ifthemost
frequentletter
hasfrequency
lessthan0.5 ,
thenallletters
willbecoded
withmore
thanonebit.
Total

1.00/
1.00

https://class.coursera.org/algo2004/quiz/feedback?submission_id=102012

5/5

You might also like