MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

ALGORITHMS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Prim’s & Kruskal’s algorithm run on a graph G and produce MCST TP and TK, respectively, and TP is different from TK. Find true statement?
A
If e is a minimum cost edge in G, e belongs to both TP and TK
B
If e is a maximum cost edge in G, e belongs to neither TP nor TK
C
All edges in G have the same weight
D
Some pair of edges in G have the same weight
Explanation: 

Detailed explanation-1: -Explanation: Kruskal’s algorithm uses a greedy algorithm approach to find the MST of the connected weighted graph.

Detailed explanation-2: -What is the weight of the minimum spanning tree using the Prim’s algorithm, starting from vertex a? Explanation: In Prim’s algorithm, we select a vertex and add it to the MST. Then we add the minimum edge from the vertex in MST to vertex not in MST. From, figure shown below weight of MST = 27.

Detailed explanation-3: -Explanation: prim’s algorithm iterates from one node to another, so it can not be applied for disconnected graph.

Detailed explanation-4: -The goal of the greedy algorithm is to find the optimal solution. There can be only 1 optimal solution.

There is 1 question to complete.