Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Kruskal's algorithm
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Complexity == For a graph with {{mvar|E}} edges and {{mvar|V}} vertices, Kruskal's algorithm can be shown to run in time {{math|''O''(''E'' log ''E'')}} time, with simple data structures. This time bound is often written instead as {{math|''O''(''E'' log ''V'')}}, which is equivalent for graphs with no isolated vertices, because for these graphs {{math|''V''/2 β€ ''E'' < ''V''<sup>2</sup>}} and the logarithms of {{mvar|V}} and {{mvar|E}} are again within a constant factor of each other. To achieve this bound, first sort the edges by weight using a [[comparison sort]] in {{math|''O''(''E'' log ''E'')}} time. Once sorted, it is possible to loop through the edges in sorted order in constant time per edge. Next, use a [[disjoint-set data structure]], with a set of vertices for each component, to keep track of which vertices are in which components. Creating this structure, with a separate set for each vertex, takes {{mvar|V}} operations and {{math|''O''(''V'')}} time. The final iteration through all edges performs two find operations and possibly one union operation per edge. These operations take [[amortized time]] {{math|''O''(''Ξ±''(''V''))}} time per operation, giving worst-case total time {{math|''O''(''E'' ''Ξ±''(''V''))}} for this loop, where {{mvar|Ξ±}} is the extremely slowly growing [[inverse Ackermann function]]. This part of the time bound is much smaller than the time for the sorting step, so the total time for the algorithm can be simplified to the time for the sorting step. In cases where the edges are already sorted, or where they have small enough integer weight to allow [[integer sorting]] algorithms such as [[counting sort]] or [[radix sort]] to sort them in linear time, the disjoint set operations are the slowest remaining part of the algorithm and the total time is {{math|''O''(''E'' ''Ξ±''(''V''))}}.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Kruskal's algorithm
(section)
Add topic