-->
当前位置:首页 > 题库 > 正文内容

单选题:Given S = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } , S[i] is initialize

Luz4年前 (2022-01-18)题库629
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

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。