Use the below recursive construction:
constructLogHeightTree($A$)
- Let $n$ be size of $A$, then:
- If $n=1$ return
- Otherwise:
- Split $A$ into $2$ sets $A_1$ and $A_2$ with $\lceil \frac{n}{2} \rceil$ and $\lfloor \frac{n}{2} \rfloor$ sizes respectively.
- Call constructLogHeightTree($A_1$) and constructLogHeightTree($A_2$).
- Take any one element of $A_1$ and any one of $A_2$, and join them using a global union find.
- Return.
Analysis
I use strong induction to show that using the above procedure, the height of the union-find tree for $n$ elements $h(n)$ will be $\lfloor \log_2 n \rfloor$.
Base step $n=1$
The height $h(1)$ would be $0$ as the tree contains only $1$ node. This shows $h(n) = \lfloor \log_2 n \rfloor = 0$ for $n=1$
Inductive step
Using the induction hypothesis, we can say that the tree produced by
constructLogHeightTree($A_1$) will have a height of $h\left( \left\lceil \frac{n}{2} \right\rceil \right) = \left\lfloor \log_2 \left\lceil \frac{n}{2} \right\rceil \right\rfloor$
constructLogHeightTree($A_2$) will have a height of $h\left( \left\lfloor \frac{n}{2} \right\rfloor \right) = \left\lfloor \log_2 \left\lfloor \frac{n}{2} \right\rfloor \right\rfloor$
As $\lceil \frac{n}{2} \rceil \ge \lfloor \frac{n}{2} \rfloor$, W.L.O.G. we can say that the root of $A_2$'s tree will get attached to ( or have its parent set to) the root $A_1$'s tree. Then the final height of the tree is
$$\begin{split}
h(n) &= \max\left( h\left( \left\lceil \frac{n}{2} \right\rceil \right) , h\left( \left\lfloor \frac{n}{2} \right\rfloor \right) + 1 \right) \\
&= \max\left( \left\lfloor \log_2 \left\lceil \frac{n}{2} \right\rceil \right\rfloor, \left\lfloor \log_2 \left\lfloor \frac{n}{2} \right\rfloor \right\rfloor + 1 \right) \\
&= \left\lfloor \log_2 \left\lfloor \frac{n}{2} \right\rfloor \right\rfloor + 1 \\
&= \left\lfloor \log_2 \cdot \left\lfloor \frac{n}{2} \right\rfloor + 1 \right\rfloor \\
&= \left\lfloor \log_2 \left( 2 \cdot \left\lfloor \frac{n}{2} \right\rfloor \right) \right\rfloor \\
&= \left\lfloor \log_2 n \right\rfloor \\
\end{split}$$