0
0
Data Structures Theoryknowledge~20 mins

Minimum spanning tree (Prim's) in Data Structures Theory - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Prim's MST Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Prim's Algorithm Process

In Prim's algorithm for finding a minimum spanning tree (MST), what is the main criterion for selecting the next edge to add to the growing MST?

AChoose the edge with the smallest weight that connects a vertex in the MST to a vertex outside the MST
BChoose the edge with the largest weight that connects any two vertices in the graph
CChoose any edge that connects two vertices already in the MST
DChoose the edge with the smallest weight that connects two vertices outside the MST
Attempts:
2 left
💡 Hint

Think about how Prim's algorithm grows the tree step by step.

📋 Factual
intermediate
2:00remaining
Prim's Algorithm Starting Point

Which of the following statements about the starting point of Prim's algorithm is true?

APrim's algorithm can start from any vertex in the graph
BPrim's algorithm starts from the vertex connected to the edge with the largest weight
CPrim's algorithm starts from the vertex with the highest degree
DPrim's algorithm must start from the vertex with the smallest label
Attempts:
2 left
💡 Hint

Consider if the choice of starting vertex affects the final MST.

🔍 Analysis
advanced
3:00remaining
Prim's Algorithm Edge Selection Sequence

Given the following weighted graph edges and starting vertex A, what is the correct order of edges added by Prim's algorithm?

A-B: 2
A-C: 3
B-C: 1
B-D: 4
C-D: 5
A2,4,1,3
B2,1,3,4
C2,1,4,3
D1,2,3,4
Attempts:
2 left
💡 Hint

Remember Prim's algorithm always picks the smallest edge connecting the MST to a new vertex.

Comparison
advanced
2:30remaining
Prim's vs Kruskal's Algorithm

Which of the following statements correctly compares Prim's and Kruskal's algorithms for finding a minimum spanning tree?

AKruskal's algorithm requires the graph to be connected, but Prim's algorithm does not
BKruskal's algorithm only works on directed graphs, while Prim's works on undirected graphs
CPrim's algorithm always produces a different MST than Kruskal's algorithm for the same graph
DPrim's algorithm grows the MST by adding edges connected to the current tree, while Kruskal's algorithm adds edges in order of increasing weight regardless of connectivity
Attempts:
2 left
💡 Hint

Think about how each algorithm selects edges and builds the MST.

Reasoning
expert
3:00remaining
Effect of Negative Edge Weights on Prim's Algorithm

Consider a connected undirected graph with some negative edge weights. What will be the effect of these negative weights on the minimum spanning tree found by Prim's algorithm?

APrim's algorithm will ignore negative edges and only use positive edges
BPrim's algorithm cannot handle negative edge weights and will produce incorrect results
CPrim's algorithm will still find a valid minimum spanning tree including negative edges if they reduce total weight
DPrim's algorithm will fail with an error when encountering negative edge weights
Attempts:
2 left
💡 Hint

Think about how Prim's algorithm chooses edges based on weight, regardless of sign.