English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2 answers

If your notation
a-> 01010101
b-> 11011011
c-> 1000010 (one digit is missing ?!?)
means that you represent your sets as strings of bits
and j-th bit is 1 iff j-th element belongs to the set then
you can compute different set operations very efficiently.

a intersect b = a AND b [in C/C++ that would be a & b]
the result has one where both arguments have ones

a union b = a OR b [in C/C++ that would be a | b ]
the result has one where at least one argument has one

a minus b = a AND (NOT b) [ a & (~b) in C/C++ ]

where NOT b is the operation that replaces 0s with 1s
and 1s with 0s.

in our example:
1) a union b = 11011111

I think c is missing the last digit, but assuming it is 0, (so we have c= 10000100) we compute
~c = 01111011 and
(a union b) minus c = 11011111 AND 01111011 =
01011011

Similarly, b union c is
11011011 OR 10000100 = 11011111
and then: a intersect (b union c) is
01010101 AND 11011111 = 01010101

Please double-check the calculations, but I hope you get the idea.

2006-09-24 22:21:45 · answer #1 · answered by Kris 1 · 0 0

...,,,,a=01010101
...,,,,b=11011011
...aUb=11011111
......-c=10111110
aUb-c=01111101

........b=11011011
........c=01000010
....bUc=11011011
........a=01010101
aXbUc=01010001 (used X to represent intercept)

2006-09-22 20:52:16 · answer #2 · answered by Helmut 7 · 0 0

fedest.com, questions and answers