Kruskals algorithm viva questions and answers

Frequently asked questions and answers of kruskal's algorithm in Computer Fundamentals of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best kruskal's algorithm Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download kruskal's algorithm FAQs in PDF form online for academic course, jobs preparations and for certification exams .

Intervew Quizz is an online portal with frequently asked interview, viva and trivia questions and answers on various subjects, topics of kids, school, engineering students, medical aspirants, business management academics and software professionals.

Question-1. What is the primary objective of Kruskal's algorithm in graph theory?

Answer-1: The primary objective of Kruskal's algorithm is to find the minimum spanning tree of a connected, undirected graph. A minimum spanning tree is a subgraph that includes all the vertices of the original graph while minimizing the total edge weight or cost.

Question-2. Describe the general procedure of Kruskal's algorithm.

Answer-2: The general procedure of Kruskal's algorithm involves the following steps:

1. Sort all the edges of the graph in ascending order of their weights.

2. Initialize an empty set to represent the minimum spanning tree.

3. Iterate through the sorted edges, adding each edge to the minimum spanning tree set if it does not create a cycle in the tree.

4. Continue this process until the minimum spanning tree includes all vertices or has \(|V| - 1\) edges, where \(|V|\) is the number of vertices in the graph.

Question-3. What are the advantages of the Kruskal algorithm?

Answer-3: The advantage of the Kruskal algorithm is to find the subset of edges that generate the tree and includes each and every vertex where the sum of all weight of the edges is a minimum. Kruskal algorithm is suitable for sparse graphs (low number of edges).

Question-4. What data structures are commonly used in implementing Kruskal's algorithm?

Answer-4: Kruskal's algorithm can be implemented using data structures such as disjoint-set data structures (also known as union-find data structures) to efficiently detect and handle cycles in the minimum spanning tree. These data structures help ensure that no cycles are formed during the tree construction.

Question-5. How does Kruskal's algorithm handle edge selection and cycle prevention?

Answer-5: Kruskal's algorithm handles edge selection by sorting all the edges by their weights in ascending order. It then iterates through the sorted edges, adding each edge to the minimum spanning tree set if adding it does not create a cycle. The algorithm uses disjoint-set data structures to check for and prevent cycles efficiently.

Question-6. What is the impact of negative edge weight on the Kruskal algorithm?

Answer-6: The negative edge weight does not have any impact on the Kruskal algorithm. In the Kruskal algorithm, the least weight edge in the graph that connects two distinct components is added to the MCST(minimum cost spanning tree). So, if there is a negative weight edge, it will not affect the working of the Kruskal algorithm.

Question-7. Can Kruskal's algorithm be used for directed graphs?

Answer-7: Kruskal's algorithm is typically used for undirected graphs. It may not work correctly for directed graphs because it relies on sorting edges by their weights, and directed edges may have different weights in each direction. For directed graphs, other algorithms like Prim's algorithm or algorithms specifically designed for directed minimum spanning trees are more appropriate.

Question-8. What is the time complexity of Kruskal's algorithm?

Answer-8: The time complexity of Kruskal's algorithm is typically \(O(E \log E)\), where \(E\) is the number of edges in the graph. The most time-consuming step is sorting the edges, which has a time complexity of \(O(E \log E)\). The subsequent steps involve efficient operations on the disjoint-set data structure, which do not significantly impact the overall time complexity.

Question-9. What is the difference between Prim's and Kruskal algorithm?

Answer-9: Prim's approach returns connected components and only works on connected graphs. Prim's approach is more efficient in dense graphs. Kruskal's approach is more efficient in sparse graphs. It constructs the shortest spanning tree beginning from the root vertex.

Question-10. When is Kruskal's algorithm preferred over other minimum spanning tree algorithms?

Answer-10: Kruskal's algorithm is preferred when:

The graph is sparse (fewer edges compared to vertices).

The edges of the graph are given in a list or can be easily sorted.

There is no requirement to prioritize certain edges over others based on weights.

The graph is undirected and connected.

Question-11. Is Kruskal algorithm capable of working with negative weights?

Answer-11: The negative weight edges do not affect their accuracy. The safe edge added to A (subset of an MST) in Kruskal's technique is always the least weight edge in the graph that connects two unique components. As a result, if there are negative weight edges, they will not affect the algorithm's progress.

Question-12. Is the MCST(minimum cost spanning tree) using the Kruskal algorithm unique?

Answer-12: The MCST(minimum cost spanning tree) using the Kruskal algorithm is unique. If all the edge weights in your graph are distinct, then the given graph has a unique MCST(minimum cost spanning tree), and the Prim and Kruskal algorithms are guaranteed to return the same tree.

Question-13. Where do we use the Kruskal algorithm?

Answer-13: We use the Kruskal algorithm to find the MCST(minimum cost spanning tree) of the undirected weighted connected graph. The Kruskal algorithm creates the MCST (minimum cost spanning tree) by locating the least weighted edge connecting two trees in the forest.

Frequently Asked Question and Answer on kruskal's algorithm

kruskal's algorithm Interview Questions and Answers in PDF form Online

kruskal's algorithm Questions with Answers

kruskal's algorithm Trivia MCQ Quiz