tripathivaishali / unionfindalgorithm Goto Github PK
View Code? Open in Web Editor NEWUnder this project, a Union-Find Class has been developed that takes integer value N from command line to determine the number of “sites.” It then generates random pairs of integers between 0 to N-1, calling connected() to determine if they are connected and union() if not. Loop until all sites are connected then print the number of connections generated. The hypothesis to be proved here is that the number of pairs generated to complete the graph (i.e. to reduce the number of components from n to 1) is ~ 1/2 n ln n where ln n is the natural logarithm of n.