- with quick find trees and a union based on the size of the trees we can make a union in $T_{am}(n)=O(log(n))$
- with quick find trees and a union based on the height of the trees we can make a find in $T(n)=O(log(n))$
But I read that using quick union trees and an union based on the size of the trees we can also have a find in $T(n)=O(log(n))$, so my question is how can this be demonstrated? What relationship is there between height and size? For example knowing that $text{size}(A)=4$ I could have both:
A A / | | 1 2 3 1 | 2 | 3
Asked By : newbie
Answered By : saadtaame
Case # 1
Say $n_1lt n_2$. The resulting tree $T$ has height $H(T)=max{H(T_1)+1, H(T_2)}$ Depending on the max we have: $H(T)le log(n_1) + 1le log(2n_1)le log(n_1 + n_2)le log(n)$ (because $n_1lt n_2$) Or, $H(T)le log(n_2)le log(n)$
Case # 2
In this case, $H(T)le max{H(T_1),H(T_2)}+1$. Again depending on the max we have: $H(T)le log(n_1)+1le log(2n_1)le log(n_1+n_2)le log(n)$ (because $n_1=n_2$) and likewise for the other one. For the base case choose $n=1$ because $H(T)=0le log(1)=0$
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/9618 Ask a Question Download Related Notes/Documents