(UVA) Galactic Bonding - Solution
In order to solve this problem, I implemented the Weighted Quick-Union. First, I calculate the distance between every node (star) to the others. Then, if the distance between two stars is not more than the given distance, I connect the stars. Finally, in order to know the number of constellations, I need to know how many components I have. Although I have studied about Union-Find in the class "Algorithms, Part I", from Coursera (you can find more details here and here ), I used my own implementation to solve this problem. import java.io.*; import java.util.*; class Main { public static Coord[] coordinates; public static int[] nodeParent; public static int[] depth; public static int count() { int[] v = new int[nodeParent.length]; for (int i = 1; i...