北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析.docx

上传人:b****6 文档编号:4691198 上传时间:2022-12-07 格式:DOCX 页数:8 大小:67.78KB
下载 相关 举报
北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析.docx_第1页
第1页 / 共8页
北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析.docx_第2页
第2页 / 共8页
北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析.docx_第3页
第3页 / 共8页
北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析.docx_第4页
第4页 / 共8页
北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析.docx_第5页
第5页 / 共8页
点击查看更多>>
下载资源
资源描述

北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析.docx

《北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析.docx》由会员分享,可在线阅读,更多相关《北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析.docx(8页珍藏版)》请在冰豆网上搜索。

北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析.docx

北大PKU慕课EDX数据结构与算法第八章图quiz答案与解析

第八章图

Problem1

(1/1分)

下图中的强连通分量的个数为多少个?

Howmanystronglyconnectedgraphsintheundergraph?

3-正确

3

3

Explanation

有向图强连通的极大子图称为该有向图的强连通分支或者强连通分量。

分别为最左边1个点组成的极大子图,中间4个点组成的极大子图和最右边1个点组成的极大子图。

分别为最左边1个点,中间4个点和最右边1个点。

Maximalstronglyconnectedsubgraphsofadirectedgrapharecalledstronglyconnectedcomponentsofthisdirectedgraph.Theyarethesubgraphconsistoftheleft-mostvertex,thesubgraphconsistof4verticesinthemiddle,,andthesubgraphconsistoftheright-mostvertexrespectively.

Problem2

(1/1分)

下面关于图的说法正确的有(多选)

Therightstatementsofgraphsinthefollowingare:

(Therearemorethanonecorrectanswers)

窗体顶端

对于无向图,所有结点的度数加起来一定是偶数。

Asforundirectedgraphs,thesumofdegreesofallverticesisdefinitelyevennumber.,将有向图的一个强连通分量中的边全部反向仍然是强连通分量。

Reversionalltheedgesofastronglyconnectedcomponentofadirectedgraph,thenthesubgraphisstillastronglyconnectedcomponent.,-正确

对于无向图,所有结点的度数加起来一定是偶数。

Asforundirectedgraphs,thesumofdegreesofallverticesisdefinitelyevennumber.

将有向图的一个强连通分量中的边全部反向仍然是强连通分量。

Reversionalltheedgesofastronglyconnectedcomponentofadirectedgraph,thenthesubgraphisstillastronglyconnectedcomponent.

对于有向图,每个结点的出度必须要等于入度。

Asfordirectedgraph,eachvertices’out-degreeisequaltoitsin-degree.

对于一个连通图,一定存在一种给边添加方向的方案使得这个图变成强连通图。

Foraconnectedgraph,theremustbeawayofdirectingalltheedgesoftheoriginalgraphtomakethegraphstronglyconnectedgraph.

窗体底端

Explanation

结点度数是边数的2倍,故一定为偶数。

Thesumofdegreesofverticesisequaltotheamountofedgetimes2,soitmustbeevennumber.

原来强连通分量中的点必须能够互达,边全部反向后,仍然能够互达。

而原来强连通分量外的点和强连通分量内的点之间的边没有变化,以前不能互达现在还是不能,这样保证了仍然是极大的强连通子图。

Intheoriginalstronglyconnectedcomponent,everypairofverticesinthesubgraphisconnectedbyapath.Afterreversion,thispropertydoesn'tchange.Andtheconnectivityoftheverticesoutsideofthesubgraphandverticesinthesubgraphdon'tchangetoo.Sowecanguaranteeitstillbethemaximalstronglyconnectedsubgraph.

所有结点的出度之和等于入度之和,但是每个结点并没有出度和入度相等的性质。

Thesumofin-degreesofallnodesisequaltothesumofout-degreesofallnodes.Butforeachnode,itdoesn'twork.

给两个结点新增一条边相连,能够形成一个连通图,但是不管怎么给边定向都不能使其成为强连通图。

Addanedgeoftwovertex,thenwecangetaconnectedgraph.Butwecan'tmakeit

stronglyconnectedgraphhoweverwedirecttheedges.

Problem3

(1/1分)

当各边上的权值满足什么要求时,宽度优先搜索算法可用来解决单源最短路径问题?

(单选)

Whatrequirementdotheweightofedgesshouldsatisfiedtomakewidth-firstsearchalgorithmcansolvesinglesourceshortestpathproblem?

(Thereisonlyonecorrectanswer)

窗体顶端

不一定相等Nolimitation.

均互不相等Eachedgeisnotequaltoeachother.

均相等Equal均相等Equal-正确

窗体底端

Explanation

均相等宽度优先搜索算法的搜索状态树是一层一层的扩展结点的,而当边权均相等时,步数越少距离越短,所以可以直接用宽度优先搜索算法解决。

EqualWidth-firstsearchalgorithm'ssearch-state-treeexpandslayerbylayer.Whentheweightofedgesisequaltoeachother,lesserstepcorrespondstoshorterdistance,sowecanusewidth-firstsearchalgorithmtosolveproblem.

均互不相等宽度优先搜索算法的搜索状态树是一层一层的扩展结点的,而当边权均相等时,步数越少距离越短,所以可以直接用宽度优先搜索算法解决。

Eachedgeisnotequaltoeachother.Width-firstsearchalgorithm'ssearch-state-treeexpandsverticeslayerbylayer.Whentheweightofedgesisequaltoeachother,lesserstepcorrespondstoshorterdistance,sowecanusewidth-firstsearchalgorithmtosolveproblem.

不一定相等宽度优先搜索算法的搜索状态树是一层一层的扩展结点的,而当边权均相等时,步数越少距离越短,所以可以直接用宽度优先搜索算法解决。

Nolimitation.Width-firstsearchalgorithm'ssearch-state-treeexpandsverticeslayerbylayer.Whentheweightofedgesisequaltoeachother,lesserstepcorrespondstoshorterdistance,sowecanusewidth-firstsearchalgorithmtosolveproblem.

Problem4

(1/1分)

下列关于最短路算法的说法正确的有:

(多选)

Therightstatementsofthefollowingare:

(Therearemorethanonecorrectanswers)

窗体顶端

当图中不存在负权回路但是存在负权边时,Dijkstra算法不一定能求出源点到所有点的最短路。

Whenthegraphdoesn'tcontaincircuitofnegativeweight,butcontainstheedgeofnegativeweight.Dijkstraalgorithmcan'tguaranteethecorrectnessofthealgorithm.,当图中不存在负权边时,Dijkstra算法能求出每对顶点间最短路径。

Whenthegraphdoesn'tcontainedgeofnegativeweight,Dijkstraalgorithmcancalculatetheshortestpathofeachpairofvertices.,-正确

当图中不存在负权回路但是存在负权边时,Dijkstra算法不一定能求出源点到所有点的最短路。

Whenthegraphdoesn'tcontaincircuitofnegativeweight,butcontainstheedgeofnegativeweight.Dijkstraalgorithmcan'tguaranteethecorrectnessofthealgorithm.

当图中不存在负权边时,Dijkstra算法能求出每对顶点间最短路径。

Whenthegraphdoesn'tcontainedgeofnegativeweight,Dijkstraalgorithmcancalculatetheshortestpathofeachpairofvertices.

当图中存在负权回路时,Dijkstra算法也一定能求出源点到所有点的最短路。

Whenthegraphcontainsthecircuitofnegativeweight,Dijkstraalgorithmcancertainlycalculatetheshortestpathformthesinglesourcetoallthevertices.

Dijkstra算法不能用于每对顶点间最短路计算。

Dijkstraalgorithmcan'tbeappliedtocalculatetheshortestpathofeachpairofvertices.

窗体底端

Explanation

当图中不存在负权回路但是存在负权边时,Dijkstra算法不一定能求出源点到所有点的最短路。

即使是只有负权边,也会导致以前已经被选出来更新其它结点最短路值的结点的最短路值被更新,造成错误。

当图中不存在负权边时,Dijkstra算法能求出每对顶点间最短路径。

可以执行多次Dijkstra算法实现这一要求。

当图中存在负权回路时,Dijkstra算法也一定能求出源点到所有点的最短路。

Dijkstra算法无法处理图中存在任何负权边的情况。

Dijkstra算法不能用于每对顶点间最短路计算。

可以执行多次Dijkstra算法实现这一要求。

Whenthegraphdoesn'tcontaincircuitofnegativeweight,butcontainstheedgeofnegativeweight.Dijkstraalgorithmcan'tguaranteethecorrectnessofthealgorithm.

Evenifthereisonlytheedgeofnegativeweight,itwouldresultinthattheshortestpathofthenodewhichbeselectedpreviouslytoupdatetheshortestpathoftheotherverticeschanges,thencauseerrors.

Whenthegraphdoesn'tcontainedgeofnegativeweight,Dijkstraalgorithmcancalculatetheshortestpathofeachpairofvertices.WecanperformDijkstraalgorithmrepeatedlytosatisfythisrequirement.

Whenthegraphcontainsthecircuitofnegativeweight,Dijkstraalgorithmcancertainlycalculatetheshortestpathformthesinglesourcetoallthevertices.

Dijkstraalgorithmcan'thandlethesituationthatgraphcontainsanyedgeofnegativeweight.

Dijkstraalgorithmcan'tbeappliedtocalculatetheshortestpathofeachpairofvertices.WecanperformDijkstraalgorithmrepeatedlytosatisfythisrequirement.

Problem5

(1/1分)

请使用Kruskal算法求出下图的最小生成树,依次写出每次被选择的合法的合并代价最小的边的编号(如果同时存在多条边满足要求,选择编号最小的)。

顶点a到顶点b(a

(不同编号之间用一个空格分隔)

PleaseuseKruskalalgorithmtothefollowinggraphandfindtheminimumspanningtree,andwritethenumberofthevalidvertexwithminimummergingcostinturn(iftherearemanyverticessatisfyrequirement,choosethevertexwithminimumnumber).Thenumberoftheedgeconnectingvertexaandvertexbisab.Liketheedgewithweight1inthegraph,itsnumberis02(differentnumbersseparatedbyablankspace).

0235142512-正确

0235142512

Explanation

Kruskal算法优先选择权值小的边,先挑选权值为1的边02,再选择权值为2的边35,再选择权值为3的边14,再选择权值为4的边25,再选择权值为5的边,只有选择12才能连接两个不同的连通分支,故答案为0235142512

EdgeswithsmallweightaregivenhighprioritytobechoseintheKruskalalgorithm.Wefirstlychoosetheedge02withweight1,thenchooseedge35withweight2,thenchooseedge14withweight3,thenchoosetheedge25withweight4,thenchoosetheedgewithweight5,andonlytheedge12canconnecttwodifferentconnectedcomponents.Sotheansweris0234142512.

Problem6

(1/1分)

请使用Prim算法从结点0出发求下图的最小生成树,依次写出每次被加入到最小生成树中边的编号(如果同时存在多条边满足要求,选择编号最小的)。

顶点a到顶点b(a

(不同编号之间用一个空格分隔)

Pleaseuseprimalgorithmstartingfromvertex0tofindtheminimumspanningtreeofthefollowinggraph,writethenumberoftheedgeaddedintotheminimumspanningtreeinturn((iftherearemanyverticessatisfyrequirement,choosethevertexwithminimumnumber).Thenumberoftheedgeconnectingvertexaandvertexbisab.Liketheedgewithweight1inthegraph,itsnumberis02(differentnumbersseparatedbyablankspace).

0225351214-正确

0225351214

Explanation

最小生成树中已经选择的顶点的集合U初始为{0},从0起,先挑选其他节点到0权值最小为1的边02,把顶点2加入U,U变为{0,2},再选择到U权值最小为4的边25,U变为{0,2,5},再选择到U权值最小为2的边35,U变为{0,2,5,3},再选择到U权值最小为5的边12,U变为{0,2,5,3,1},再选择到U权值最小为3的边14,U变为{0,2,5,3,1,4},结束,答案为0225351214

Theoriginalsetoftheselectedverticesoftheminimumspanningtreeis{0}.Wefirstlyselecttheedgewiththeminimumweightofedgeswhichconnectvertex0andothervertices.Soweselectedge02withweight1andaddvertex2intoU,thenUbecomes{0,2}.Next,inthesetofedgeswhichconnectUandothers,weselecttheedge25withtheminimumweight4,thenUbecomes{0,2,5}.Next,inthesetofedgeswhichconnectUandothers,weselecttheedge35withtheminimumweight2,thenUbecomes{0,2,5,3}.Similarly,thenweselecttheedge12withtheminimumweight12,Ubecomes{0,2,5,3,1}.Thenweselecttheedge14withtheminimumweight3,thenUbecomes{0,2,5,3,1,4},over.Theansweris0225351214

Problem7

(本题共有1分)

题图为一无向图,分别写出从顶点1出发,按深度优先搜索遍历算法得到的顶点序列,和按广度优先搜索遍历算法得到的顶点序列

注意:

1.优先访问编号小的结点

2.顶点序列内无空格,先写深度优先搜索遍历序列,再写广度优先搜索遍历序列。

3.深度优先搜索遍历序列和广度优先搜索遍历序列之间用空格隔开

Thefollowinggraphisanundirectedgraph,pleasewritetheverticessequencesobtainedbythedepth-firstsearchtraversalalgorithmandwidth-firstsearchtraversalalgorithmrespectively.

Notice:

1.Thevertexwithsmallernumbershouldhavehigherprioritytobevisited.

2.Thereisnoblankspaceamongtheverticessequences,writethesequenceproducedbythedepth-firstsearchtraversalalgorithmatfirst,thenwritetheanotherone.

3.Theretwosequencesshouldbeseparatedbyablankspace.

123456123564

Explanation

根据深度优先定义,先访问1,依次是2、3、4、5、6,注意是无向图。

广度优先是一层一层访问,即123564,答案为123456123564

Accordingtothedefinitionofthedepth-first,wefirstlyvisitvertex1,then2,3,4,5,6inturn,youshouldnoticedthatit’sund

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 理化生

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1