@@ -0,0 +1,864 @@
+public class QuickUnionUF%0A    %7B%0A        private int%5B%5D id;%0A        %0A        %0A        // Set id of each object to itself%0A        public QuickUnionUF(int N) %7B%0A            id = new int%5BN%5D;%0A            for (int i = 0; i %3C N; i++) %7B%0A                id%5Bi%5D = i; //set id of each object to itself%0A            %7D%0A        %7D%0A        %0A        // Chase parent pointers until reach root%0A        private int root(int i) %7B%0A            while (i != id%5Bi%5D) %7B%0A                i = id%5Bi%5D;%0A            %7D%0A            %0A            return i;%0A        %7D%0A%0A        // Check if p and q have same root%0A        public boolean connected(int p, int q) %7B%0A            return root(p) == root(q);%0A        %7D%0A        %0A        // Change root of p to point to root of q%0A        public void union(int p, int q) %7B%0A            int i = root(p);%0A            int j = root(q);%0A            id%5Bi%5D = j;%0A        %7D%0A    %7D%0A

Create QuickUnionUF.java