4

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?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Sam
  • 934
  • 2
  • 11
  • 21

1 Answers1

5

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
  • 14,234
  • 2
  • 31
  • 52