A Minimum Spanning Tree is a subset of edges in a connected, weighted graph that connects all vertices together without any cycles and with the minimum possible total edge weight.
Click to reveal answer
beginner
What is the main idea behind Kruskal's Algorithm?
Kruskal's Algorithm builds the MST by sorting all edges by weight and adding them one by one to the MST, skipping edges that would form a cycle, until all vertices are connected.
Click to reveal answer
intermediate
Why do we use a Disjoint Set (Union-Find) data structure in Kruskal's Algorithm?
The Disjoint Set helps efficiently check if adding an edge will create a cycle by tracking which vertices are already connected, allowing quick union and find operations.
Click to reveal answer
intermediate
What is the time complexity of Kruskal's Algorithm?
The time complexity is O(E log E), where E is the number of edges, mainly due to sorting edges. Union-Find operations are almost constant time.
Click to reveal answer
advanced
What happens if the graph is not connected when running Kruskal's Algorithm?
Kruskal's Algorithm will find a Minimum Spanning Forest, which is a set of MSTs for each connected component, since it cannot connect all vertices in a disconnected graph.
Click to reveal answer
What is the first step in Kruskal's Algorithm?
ASort all edges by their weight
BPick any vertex as the starting point
CCreate adjacency list
DRemove all cycles from the graph
✗ Incorrect
Kruskal's Algorithm starts by sorting all edges from smallest to largest weight.
Which data structure is commonly used to detect cycles in Kruskal's Algorithm?
AStack
BQueue
CDisjoint Set (Union-Find)
DBinary Search Tree
✗ Incorrect
Disjoint Set (Union-Find) efficiently detects cycles by tracking connected components.
If adding an edge creates a cycle, what does Kruskal's Algorithm do?
AAdds the edge anyway
BRemoves a vertex
CRestarts the algorithm
DSkips the edge
✗ Incorrect
Kruskal's Algorithm skips edges that would create cycles to keep the MST valid.
What does Kruskal's Algorithm produce if the graph is disconnected?
AMinimum Spanning Forest
BNo output
CA single MST
DA cycle
✗ Incorrect
It produces a Minimum Spanning Forest, which is MSTs for each connected part.
What is the main factor affecting Kruskal's Algorithm time complexity?
ANumber of vertices
BNumber of edges
CNumber of cycles
DNumber of connected components
✗ Incorrect
Sorting edges by weight dominates the time complexity, which depends on the number of edges.
Explain step-by-step how Kruskal's Algorithm finds a Minimum Spanning Tree.
Think about sorting edges and checking cycles with Union-Find.
You got /5 concepts.
Describe how the Disjoint Set data structure helps in Kruskal's Algorithm.
Focus on cycle detection and efficient merging.
You got /4 concepts.
Practice
(1/5)
1. What is the main goal of Kruskal's algorithm in graph theory?
easy
A. To detect cycles in a graph
B. To find the shortest path between two nodes
C. To find the minimum spanning tree of a graph
D. To sort the vertices of a graph
Solution
Step 1: Understand Kruskal's algorithm purpose
Kruskal's algorithm is designed to find a subset of edges that connects all vertices with the minimum total edge weight and no cycles.
Step 2: Compare with other graph problems
Shortest path and cycle detection are different problems solved by other algorithms like Dijkstra or DFS.
Final Answer:
To find the minimum spanning tree of a graph -> Option C
Quick Check:
Minimum Spanning Tree = Find minimum edges connecting all nodes [OK]
Hint: Kruskal always builds minimum spanning tree by edges [OK]
Common Mistakes:
Confusing MST with shortest path
Thinking Kruskal detects cycles only
Assuming it sorts vertices
2. Which Java data structure is commonly used to efficiently check and union sets in Kruskal's algorithm?
easy
A. Disjoint Set (Union-Find)
B. PriorityQueue
C. ArrayList
D. HashMap
Solution
Step 1: Identify the need for set operations
Kruskal's algorithm requires checking if two vertices belong to the same set and merging sets without cycles.
Step 2: Match data structure to operations
Disjoint Set (Union-Find) supports fast union and find operations, ideal for this purpose.
Final Answer:
Disjoint Set (Union-Find) -> Option A
Quick Check:
Union-Find = fast set checks and merges [OK]
Hint: Use Union-Find to detect cycles fast in Kruskal [OK]
Common Mistakes:
Using ArrayList for set operations
Confusing PriorityQueue with Union-Find
Using HashMap which is not efficient here
3. What is the output MST edges after running Kruskal's algorithm on this graph?