1.The array representation of a disjoint set containing numbers 0 to 8 is given by { 1, -4, 1, 1, -3, 4, 4, 8, -2 }. Then to union the two sets which contain 6 and 8 (with union-by-size), the index of the resulting root and the value stored at the root are:
选项
A
1 and -6
B
4 and -5
C
8 and -5
D
8 and -6
2.The array representation of a disjoint set is given by { 4, 6, 5, 2, -3, -4, 3 }. If the elements are numbered from 1 to 7, the resulting array after invoking Union(Find(7),Find(1)) with union-by-size and path-compression is:
选项
A
{ 4, 6, 5, 2, 6, -7, 3 }
B
{ 4, 6, 5, 2, -7, 5, 3 }
C
{ 6, 6, 5, 6, -7, 5, 5 }
D
{ 6, 6, 5, 6, 6, -7, 5 }
3.The array representation of the disjoint sets is given by {2, –4, 2, 3, -3, 5, 6, 9, -2}. Keep in mind that the elements are numbered from 1 to 9. After invoking Union(Find(4), Find(6)) with union-by-size, which elements will be changed in the resulting array?
选项
A
a. elements of index 2 and 5
B
a. elements of index 2 and 6
C
a. elements of index 4 and 5
D
a. elements of index 4 and 6
4.In a disjoint set problem, given a set of m elements S = { 1, 2, 3, …, m } and n ( 0<n<m ) distinct relations, the set S must have __ equivalence classes.
7.In a disjoint set problem, given a set of m elements S = { 1, 2, 3, …, m } and n ( 0<n<m ) distinct relations, the set S must have __ equivalence classes.