study algorithms in c: add weighted quickunion with path compression by halving