views:

25

answers:

1

Hi,

I'm having trouble understanding the following diagram:

alt text

Why is A linked to D instead of B? Why is C linked to F instead of D?

+1  A: 

The rule for union by rank is to attach the smallest tree to the root of the largest tree.

At the first step A is united to D (this is just an example I guess - you could do any other way), so after union(A, D) you can have either A_0 -> D_1 or D_O -> A_1 since the 2 singleton trees have the same rank you pick one at random, in this case D, to be the root.

Mau