add O(logN) version on Unionfind.cpp