单选题:Given S = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } , S[i] is initialize
Given a disjoint set S = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } with array representation. S[i] is initialized to be -1, hence the height of root is 1. If union-by-rank (union-by-height and find-with-path-compression) is used, please list the resulting array after invoking Union(1,2), Union(3,4), Union(1,3), Union(3,5), Union(6,7), Union(1,7), Union(7,8), and Union(4,10).
A.{-3, 1, 1, 3, 1, 1, 1, 1, -1, -1}
B.{-3, 1, 1, 3, 1, -2, 6, -1, -1, -1}
C.{-2, 1, 1, 3, 1, 1, 1, 1, -1, 1}
D.{-2, 1, 1, 1, 1, 1, 1, 1, -1, 1}
答案:D
A.{-3, 1, 1, 3, 1, 1, 1, 1, -1, -1}
B.{-3, 1, 1, 3, 1, -2, 6, -1, -1, -1}
C.{-2, 1, 1, 3, 1, 1, 1, 1, -1, 1}
D.{-2, 1, 1, 1, 1, 1, 1, 1, -1, 1}
答案:D