Let there be a list of many Sets named (S)
Perform a pass through all elements of S, to determine the range (LOW .. HIGH).
Create an array of pointer to Set, of dimensions (LOW, HIGH), named (M).
do
Init all elements of M to NULL.
Iterate though S, processing them one Set at a time, named (Si).
Permutate all ordered pairs in Si. (P1, P2) where P1 <= P2.
For each pair examine M(P1, P2)
if M(P1, P2) is NULL
Continue with the next pair.
otherwise
Merge Si, into the Set pointed to by, M(P1, P2).
Remove Si from S, as it has been merged.
Move on to processing Set S(i + 1)
If Si was not merged,
Permutate again through Si
For each pair, make M(P1, P2) point to Si.
while At least one set was merged during the pass.
我的頭說,這是關於訂單(2N LN N)。 帶上一粒鹽吧。
集合中的值的範圍是多少? – 2008-11-23 20:35:01
有沒有整數?他們可以在一套內重複嗎? – EvilTeach 2008-11-23 20:38:08
集合中的值是整數,並且它們不在每個集合中重複 – bajafresh4life 2008-11-23 20:47:32