Just like this:
int find(int x)
{
if(f[x]==x) return x;
return find(f[x]);
}
void merge(int x,int y)
{
x=find(x);y=find(y);
if(size[x]<size[y]) swap(x,y);
f[y]=x;size[x]+=size[y];
}
I've knew that the complexity of merging by MAX-depth is $$$O(logN)$$$. But I can't figure out the proof that the complexity of merging by size is $$$O(logN)$$$. Can anyone help?