有n的不同大小的set
t1,t2,...,tn
將其n個set全部交集(這裡用and當運算符號)起來
t1 and t2 and ... and tn
請問如何做效率能最好?
比如
A = {1, 2, 3}
B = {2, 3}
C = {1, 2}
D = {2}
(A and B) and (C and D)
= {2, 3} and {2}
= {2}
(((A and D) and B) and C
= (({2} and B) and C)
= {2} and C
= {2}
有不同的運算順序
假設集合A與B作交集 n=|A| m=|B|
只需要O(n+m)