0% found this document useful (0 votes)
11 views

Introduction To Kruskals Algorithm

Uploaded by

Bbbb Bbbb
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Introduction To Kruskals Algorithm

Uploaded by

Bbbb Bbbb
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Introduction to

Kruskal's Algorithm
Kruskal's algorithm is a fundamental technique in computer science for finding
the minimum spanning tree (MST) of a weighted, undirected graph. It is a greedy
algorithm that gradually constructs the MST by adding the cheapest available
edges, ensuring no cycles are formed.

Name-Aniket Subudhi
Minimum Spanning Tree (MST) Problem

The MST problem seeks to find the subset of edges that connect all nodes in a graph with the minimum total edge
weight. Kruskal's algorithm provides an efficient solution to this problem, making it a widely used technique in
network optimization, transportation planning, and other graph-based applications.
Kruskal's Algorithm Approach
Sort Edges 1
The algorithm begins by sorting the
graph's edges in ascending order of their
weights. 2 Union-Find
It then uses a Union-Find data structure to
track connected components and avoid
Add Edges 3 creating cycles.
Edges are added to the MST one by one,
starting with the lightest edge, as long as
they don't create a cycle.
Sorting Edges by Weight
Why Sort? Sorting Techniques Optimizations

Sorting the edges by weight is a Common sorting algorithms like In practice, the sorting step can
crucial step in Kruskal's Quicksort or Mergesort can be be optimized further by using
algorithm, as it allows the used to sort the edges in O(E log more efficient algorithms or by
algorithm to efficiently identify E) time, where E is the number taking advantage of the specific
and add the cheapest available of edges in the graph. properties of the input graph.
edges to the MST.
Union-Find Data Structure

1 Tracking Connected Components 2 Find Operation


The Find operation determines the root or
The Union-Find data structure allows Kruskal's representative of a given node's set, allowing
algorithm to efficiently track the connected the algorithm to check if two nodes are in the
components in the graph, ensuring that no same connected component.
cycles are formed.

3 Union Operation 4 Time Complexity


The Union operation merges the sets With the use of path compression and union by
containing two nodes, effectively connecting rank techniques, the Union-Find data structure
the corresponding components in the graph. can achieve nearly constant-time performance
for both Find and Union operations.
Adding Edges to the MST

Select Edge Union Sets Add to MST


Kruskal's algorithm selects the The algorithm then uses the The selected edge is then added
lightest edge from the sorted list Union-Find data structure to to the growing minimum
that does not create a cycle in merge the sets containing the spanning tree.
the current MST. two nodes of the selected edge.
Example

Final MST
Time Complexity of Kruskal's Algorithm
O(E log E) Nearly Constant-Time Practical Efficiency
Union-Find
The time complexity of Due to its efficient
Kruskal's algorithm is With the use of advanced implementation and ability to
dominated by the sorting of techniques, the Union-Find handle large graphs, Kruskal's
the edges, which takes O(E operations can be performed algorithm is widely used in
log E) time, where E is the in nearly constant time, real-world applications, such
number of edges in the graph. further improving the overall as network optimization and
efficiency of the algorithm. transportation planning.
Applications of Kruskal's Algorithm

Network Power Grid Design Clustering Analysis Image


Optimization Segmentation
Kruskal's algorithm is In the design of The MST constructed Kruskal's algorithm has
used to find the electrical power grids, by Kruskal's algorithm been adapted for image
minimum cost network Kruskal's algorithm can be used as a basis segmentation, where it
that connects all nodes, helps determine the for clustering helps partition an image
optimizing the minimum cost algorithms, which group into meaningful regions
infrastructure for configuration that similar data points based on pixel
telecommunication, ensures reliable power together in various similarities.
transportation, and other distribution to all applications.
network-based systems. connected nodes.

You might also like