n 個の非素集合に編成された要素の宇宙があります。ユニオン/インターセクション/差分演算子を使用して、これらのセットを使用して m 式を作成しました。したがって、要素が与えられた場合、これらの m 式を評価して、どの「派生」セットにその要素が含まれているかを調べる必要があります。「派生」セットを計算したくありません。時間とスペースが非常に非効率になるからです。式を見るだけで、要素が派生セットの 1 つに含まれるかどうかを判断する方法はありますか? たとえば、式が C = AUB で、要素がセット A にある場合、セット C にあると言えます。この性質の計算を実行する C ライブラリはありますか?
1 に答える
4
if im not mistake, let e = the element
replace each set A, B with true if e is in the set, false if its not. Then, convert the set operators to their logical equivalents, and evaluate the expression as boolean. It should all map well to boolean operators, even xor and stuff.
for example, if e is in both A B, but not D
C = (A U B) xor D
it would be in C because
C = (true or true) xor false
-> (true) xor false
-> true
That could be pretty fast if you can quickly find if an element is in a set
于 2012-05-22T06:44:52.370 に答える