北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析Word格式.docx
- 文档编号:17626099
- 上传时间:2022-12-07
- 格式:DOCX
- 页数:8
- 大小:67.78KB
北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析Word格式.docx
《北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析Word格式.docx》由会员分享,可在线阅读,更多相关《北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析Word格式.docx(8页珍藏版)》请在冰豆网上搜索。
分别为最左边1个点,中间4个点和最右边1个点。
Maximalstronglyconnectedsubgraphsofadirectedgrapharecalledstronglyconnectedcomponentsofthisdirectedgraph.Theyarethesubgraphconsistoftheleft-mostvertex,thesubgraphconsistof4verticesinthemiddle,,andthesubgraphconsistoftheright-mostvertexrespectively.
Problem2
下面关于图的说法正确的有(多选)
Therightstatementsofgraphsinthefollowingare:
(Therearemorethanonecorrectanswers)
窗体顶端
对于无向图,所有结点的度数加起来一定是偶数。
Asforundirectedgraphs,thesumofdegreesofallverticesisdefinitelyevennumber.,将有向图的一个强连通分量中的边全部反向仍然是强连通分量。
Reversionalltheedgesofastronglyconnectedcomponentofadirectedgraph,thenthesubgraphisstillastronglyconnectedcomponent.,-正确
Asforundirectedgraphs,thesumofdegreesofallverticesisdefinitelyevennumber.
将有向图的一个强连通分量中的边全部反向仍然是强连通分量。
Reversionalltheedgesofastronglyconnectedcomponentofadirectedgraph,thenthesubgraphisstillastronglyconnectedcomponent.
对于有向图,每个结点的出度必须要等于入度。
Asfordirectedgraph,eachvertices’out-degreeisequaltoitsin-degree.
对于一个连通图,一定存在一种给边添加方向的方案使得这个图变成强连通图。
Foraconnectedgraph,theremustbeawayofdirectingalltheedgesoftheoriginalgraphtomakethegraphstronglyconnectedgraph.
窗体底端
结点度数是边数的2倍,故一定为偶数。
Thesumofdegreesofverticesisequaltotheamountofedgetimes2,soitmustbeevennumber.
原来强连通分量中的点必须能够互达,边全部反向后,仍然能够互达。
而原来强连通分量外的点和强连通分量内的点之间的边没有变化,以前不能互达现在还是不能,这样保证了仍然是极大的强连通子图。
Intheoriginalstronglyconnectedcomponent,everypairofverticesinthesubgraphisconnectedbyapath.Afterreversion,thispropertydoesn'
tchange.Andtheconnectivityoftheverticesoutsideofthesubgraphandverticesinthesubgraphdon'
tchangetoo.Sowecanguaranteeitstillbethemaximalstronglyconnectedsubgraph.
所有结点的出度之和等于入度之和,但是每个结点并没有出度和入度相等的性质。
Thesumofin-degreesofallnodesisequaltothesumofout-degreesofallnodes.Butforeachnode,itdoesn'
twork.
给两个结点新增一条边相连,能够形成一个连通图,但是不管怎么给边定向都不能使其成为强连通图。
Addanedgeoftwovertex,thenwecangetaconnectedgraph.Butwecan'
tmakeit
stronglyconnectedgraphhoweverwedirecttheedges.
Problem3
当各边上的权值满足什么要求时,宽度优先搜索算法可用来解决单源最短路径问题?
(单选)
Whatrequirementdotheweightofedgesshouldsatisfiedtomakewidth-firstsearchalgorithmcansolvesinglesourceshortestpathproblem?
(Thereisonlyonecorrectanswer)
不一定相等Nolimitation.
均互不相等Eachedgeisnotequaltoeachother.
均相等Equal均相等Equal-正确
均相等宽度优先搜索算法的搜索状态树是一层一层的扩展结点的,而当边权均相等时,步数越少距离越短,所以可以直接用宽度优先搜索算法解决。
EqualWidth-firstsearchalgorithm'
ssearch-state-treeexpandslayerbylayer.Whentheweightofedgesisequaltoeachother,lesserstepcorrespondstoshorterdistance,sowecanusewidth-firstsearchalgorithmtosolveproblem.
均互不相等宽度优先搜索算法的搜索状态树是一层一层的扩展结点的,而当边权均相等时,步数越少距离越短,所以可以直接用宽度优先搜索算法解决。
Eachedgeisnotequaltoeachother.Width-firstsearchalgorithm'
ssearch-state-treeexpandsverticeslayerbylayer.Whentheweightofedgesisequaltoeachother,lesserstepcorrespondstoshorterdistance,sowecanusewidth-firstsearchalgorithmtosolveproblem.
不一定相等宽度优先搜索算法的搜索状态树是一层一层的扩展结点的,而当边权均相等时,步数越少距离越短,所以可以直接用宽度优先搜索算法解决。
Nolimitation.Width-firstsearchalgorithm'
Problem4
下列关于最短路算法的说法正确的有:
(多选)
Therightstatementsofthefollowingare:
当图中不存在负权回路但是存在负权边时,Dijkstra算法不一定能求出源点到所有点的最短路。
Whenthegraphdoesn'
tcontaincircuitofnegativeweight,butcontainstheedgeofnegativeweight.Dijkstraalgorithmcan'
tguaranteethecorrectnessofthealgorithm.,当图中不存在负权边时,Dijkstra算法能求出每对顶点间最短路径。
tcontainedgeofnegativeweight,Dijkstraalgorithmcancalculatetheshortestpathofeachpairofvertices.,-正确
tguaranteethecorrectnessofthealgorithm.
当图中不存在负权边时,Dijkstra算法能求出每对顶点间最短路径。
tcontainedgeofnegativeweight,Dijkstraalgorithmcancalculatetheshortestpathofeachpairofvertices.
当图中存在负权回路时,Dijkstra算法也一定能求出源点到所有点的最短路。
Whenthegraphcontainsthecircuitofnegativeweight,Dijkstraalgorithmcancertainlycalculatetheshortestpathformthesinglesourcetoallthevertices.
Dijkstra算法不能用于每对顶点间最短路计算。
Dijkstraalgorithmcan'
tbeappliedtocalculatetheshortestpathofeachpairofvertices.
即使是只有负权边,也会导致以前已经被选出来更新其它结点最短路值的结点的最短路值被更新,造成错误。
可以执行多次Dijkstra算法实现这一要求。
Dijkstra算法无法处理图中存在任何负权边的情况。
Whenthegraphdoesn'
tguaranteethecorrectnessofthealgorithm.
Evenifthereisonlytheedgeofnegativeweight,itwouldresultinthattheshortestpathofthenodewhichbeselectedpreviouslytoupdatetheshortestpathoftheotherverticeschanges,thencauseerrors.
tcontainedgeofnegativeweight,Dijkstraalgorithmcancalculatetheshortestpathofeachpairofvertices.WecanperformDijkstraalgorithmrepeatedlytosatisfythisrequirement.
Whenthegraphcontainsthecircuitofnegativeweight,Dijkstraalgorithmcancertainlycalculatetheshortestpathformthesinglesourcetoallthevertices.
Dijkstraalgorithmcan'
thandlethesituationthatgraphcontainsanyedgeofnegativeweight.
tbeappliedtocalculatetheshortestpathofeachpairofvertices.WecanperformDijkstraalgorithmrepeatedlytosatisfythisrequirement.
Problem5
请使用Kruskal算法求出下图的最小生成树,依次写出每次被选择的合法的合并代价最小的边的编号(如果同时存在多条边满足要求,选择编号最小的)。
顶点a到顶点b(a<
b)之间的边编号为ab,例如图中权值为1的边编号为02。
(不同编号之间用一个空格分隔)
PleaseuseKruskalalgorithmtothefollowinggraphandfindtheminimumspanningtree,andwritethenumberofthevalidvertexwithminimummergingcostinturn(iftherearemanyverticessatisfyrequirement,choosethevertexwithminimumnumber).Thenumberoftheedgeconnectingvertexaandvertexbisab.Liketheedgewithweight1inthegraph,itsnumberis02(differentnumbersseparatedbyablankspace).
0235142512-正确
0235142512
Kruskal算法优先选择权值小的边,先挑选权值为1的边02,再选择权值为2的边35,再选择权值为3的边14,再选择权值为4的边25,再选择权值为5的边,只有选择12才能连接两个不同的连通分支,故答案为0235142512
EdgeswithsmallweightaregivenhighprioritytobechoseintheKruskalalgorithm.Wefirstlychoosetheedge02withweight1,thenchooseedge35withweight2,thenchooseedge14withweight3,thenchoosetheedge25withweight4,thenchoosetheedgewithweight5,andonlytheedge12canconnecttwodifferentconnectedcomponents.Sotheansweris0234142512.
Problem6
请使用Prim算法从结点0出发求下图的最小生成树,依次写出每次被加入到最小生成树中边的编号(如果同时存在多条边满足要求,选择编号最小的)。
Pleaseuseprimalgorithmstartingfromvertex0tofindtheminimumspanningtreeofthefollowinggraph,writethenumberoftheedgeaddedintotheminimumspanningtreeinturn((iftherearemanyverticessatisfyrequirement,choosethevertexwithminimumnumber).Thenumberoftheedgeconnectingvertexaandvertexbisab.Liketheedgewithweight1inthegraph,itsnumberis02(differentnumbersseparatedbyablankspace).
0225351214-正确
0225351214
最小生成树中已经选择的顶点的集合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
根据深度优先定义,先访问1,依次是2、3、4、5、6,注意是无向图。
广度优先是一层一层访问,即123564,答案为123456123564
Accordingtothedefinitionofthedepth-first,wefirstlyvisitvertex1,then2,3,4,5,6inturn,youshouldnoticedthatit’sund
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 北大PKU 慕课 EDX 数据结构与算法 第八章图 quiz答案与解析 北大 PKU 数据结构 算法 第八 quiz 答案 解析