Added weighted quickunion implementation with path compression