Starting from Vertex 0 as the first visited node, which vertex will be visited third by Prim’s algorithm?单项选择题

A
Vertex 1
B
Vertex 0
C
Vertex 2
D
Vertex 3
登录即可查看完整答案
我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。
类似问题
Which of the following statements are TRUE regarding the behavior and results of Prim’s algorithm and Kruskal’s algorithm on a connected, undirected graph 𝐺 = ( 𝑉 , 𝐸 ) ? Select ALL that apply
Select all edges that make up a Minimum Spanning Tree in the following graph. The edge weights are shown in red.
Prims_Alg_5 This question relates to the use of the Graph Abstract Data Type (ADT) implemented with an Adjacency Map, as covered in class. Below is the pseudocode for Prim’s Algorithm, which is used to compute a Minimum Spanning Tree (MST) for a connected, undirected, weighted graph: PrimJarnikMST(Graph g): d = empty map // d[v] = min edge weight to connect v tree = empty list // stores MST edges pq = AdaptableHeapPriorityQueue() pqlocator = empty map // maps vertex to its entry in pq for each vertex v in g.vertices(): if d is empty: d[v] = 0 else: d[v] = ∞ pqlocator[v] = pq.add(d[v], (v, None)) while pq is not empty: (key, (u, edge)) = pq.remove_min() remove u from pqlocator if edge ≠ None: add edge to tree for each link in g.incident_edges(u): v = link.opposite(u) if v in pqlocator: weight = link.element() if weight < d[v]: d[v] = weight pq.update(pqlocator[v], d[v], (v, link)) return tree Which condition guarantees that Prim’s algorithm terminates after building the MST?
Prims_2 This question relates to the use of the Graph Abstract Data Type (ADT) implemented with an Adjacency Map, as covered in class. We are using Prim’s algorithm to form a Minimum Spanning Tree (MST) for a connected, undirected, weighted graph. Below is the pseudocode for Prim’s algorithm: PrimJarnikMST(Graph g): d = empty map // d[v] = min edge weight to connect v tree = empty list // stores MST edges pq = AdaptableHeapPriorityQueue() pqlocator = empty map // maps vertex to its entry in pq for each vertex v in g.vertices(): if d is empty: d[v] = 0 // start vertex else: d[v] = ∞ pqlocator[v] = pq.add(d[v], (v, None)) while pq is not empty: (key, (u, edge)) = pq.remove_min() remove u from pqlocator if edge ≠ None: add edge to tree for each link in g.incident_edges(u): v = link.opposite(u) if v in pqlocator: weight = link.element() if weight < d[v]: d[v] = weight pq.update(pqlocator[v], d[v], (v, link)) return tree We have just completed visiting vertex 4, as part of executing Prim’s algorithm. Using the current state of the distance and parent tables (shown below), and based on the priority queue selection logic in the pseudocode above: Which vertex will be visited next by the algorithm?
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!