Challenge your understanding of Minimum Spanning Trees and their construction through Kruskal's and Prim’s algorithms. This quiz covers foundational concepts, step-by-step processes, and key properties critical for graph algorithms and efficient network design.
In Kruskal’s algorithm, which edge is chosen at each step during the construction of a minimum spanning tree in a connected, undirected graph?
Explanation: Kruskal’s algorithm selects the edge with the least weight that does not form a cycle to ensure the minimal total weight of the spanning tree. Choosing the highest weight would lead to a maximum, not minimum, spanning tree. Selecting edges from previously used vertices or choosing randomly does not guarantee minimum weight or tree structure. The avoidance of cycles is crucial to preserve tree properties.
When using Prim’s algorithm on a weighted graph, what impact does the starting vertex have on the final minimum spanning tree?
Explanation: For graphs with multiple edges of equal minimal weights, the choice of starting vertex may lead to different, yet still minimum weight, spanning trees. The total cost, however, remains the same. The order of numbering does not matter, and Prim's algorithm specifically requires a starting vertex. Therefore, only the first option accurately describes the impact.
Why is cycle detection necessary in Kruskal's algorithm when building a minimum spanning tree?
Explanation: Kruskal's algorithm must avoid cycles to maintain the tree property: a connected, acyclic graph spanning all vertices. The goal is not minimizing edge count (since a tree has exactly n-1 edges by definition) nor to maximize cost. Spanning trees never require reaching vertices more than once.
During each iteration, how does Prim’s algorithm select the next edge to add to the growing minimum spanning tree?
Explanation: Prim's algorithm always extends the tree by adding the minimum-weight edge that connects to a new vertex outside the current tree. Selecting maximum weight edges, ignoring weights, or forming cycles does not ensure minimum total weight or valid tree formation, so only the first option correctly describes the process.
Which statement best defines a minimum spanning tree in an undirected, connected weighted graph?
Explanation: A minimum spanning tree must connect all vertices (spanning), have minimum total edge weight, and must not contain cycles. It is not a partial connection or concerned with the shortest path between only two nodes, and it never includes all edges if that creates cycles.
If all the edge weights of a connected graph are distinct, what is true about the minimum spanning tree produced by Kruskal’s and Prim’s algorithms?
Explanation: When all edge weights are distinct, there can only be one minimum spanning tree; both Kruskal's and Prim's algorithms will produce this same MST. The uniqueness derives from the fact that no ties exist for selecting edges. Both alternative choices stating multiple trees or algorithm incompatibility are inaccurate.
Why are Kruskal’s and Prim’s algorithms considered greedy algorithms when constructing minimum spanning trees?
Explanation: Both algorithms greedily pick the next best option available by local criteria (minimum weight edge) without considering future consequences, aiming for a globally minimum cost. They do not try all possible trees, nor do they use recursive or backtracking methods, and they consider edge weights throughout the process.
For a graph with V vertices and E edges, what is the typical time complexity of Kruskal’s algorithm using a sorting-based approach?
Explanation: Kruskal’s algorithm mainly spends time sorting the edges, which takes O(E log E) time. O(V^2) is typical for adjacency-matrix-based Prim's implementations. O(E + V) applies to simpler traversal algorithms, and O(V log V) is not sufficient for edge-dominated processes.
What result do Kruskal’s and Prim’s algorithms produce when given an undirected graph that is not connected?
Explanation: With disconnected graphs, both algorithms create a minimum spanning forest, generating a separate minimum spanning tree for each connected component. They do not form cycles across all vertices, neither will they always error, nor can they add imaginary edges to artificially connect the graph.
Which data structure is commonly used in Kruskal’s algorithm to efficiently keep track of connected components and detect cycles?
Explanation: The disjoint-set, also called Union-Find, lets Kruskal’s algorithm quickly determine if two vertices belong to the same tree, preventing cycles when adding edges. Binary search trees organize elements but do not manage components. Heaps/priority queues are more relevant to Prim’s selection process. An adjacency matrix represents graph connectivity but is inefficient for cycle detection.