Professional Documents
Culture Documents
Prerequisites
0.2: Set Operations
(From “Probability & Statistics with Applications to Computing” by Alex Tsun)
Example(s)
1. If we were talking about the set of fruits a supermarket might sell S, we might have S =
{apple, watermelon, pear, strawberry} and U = {all fruits}. We might want to know which
fruits the supermarket doesn’t sell, which would be denoted S C (defined later). This requires a
universal set of all fruits that we can check with to see which are missing from S.
2. If we were talking about the set of kinds of cars Bill Gates owns, that might be the set T . There
must be a universal set U of possible kinds of cars that exist, if we wanted to list out which
ones he was missing T C .
The union of A and B is denoted A∪B. It contains elements in A or B, or both (without duplicates).
So x ∈ A ∪ B if and only if x ∈ A or x ∈ B.
The image below shows in red the union of A and B: A ∪ B. The outer rectangle is the univeral set U.
1
2 Probability & Statistics with Applications to Computing 0.2
The image below shows in red the intersection of A and B: A ∩ B. The outer rectangle is the univeral set U.
The set difference of A with B is denoted, A \ B. It contains elements of A which are not in B. So
x ∈ A \ B if and only if x ∈ A and x ∈
/ B.
The image below shows in red the set different of A with B: A \ B. The outer rectangle is the univeral set
U.
0.2 Probability & Statistics with Applications to Computing 3
Example(s)
Let A = {1, 3}, B = {2, 3, 4}, and U = {1, 2, 3, 4, 5}. Solve for: A ∩ B, A ∪ B, B \ A, A \ B, (A ∪ B)C ,
AC , B C , and AC ∩ B C .
Solution
• A ∪ B = {1, 2, 3, 4}, as these are all the elements in either A or B. Note we dropped the duplicate 3,
since sets cannot contain duplicates.
• B \ A = {2, 4}, as these are the elements of B which are not in A.
• A \ B = {1}, as this is the only element of A which is not an element of B.
• (A ∪ B)C = {5}, as by definition (A ∪ B)C = U \ (A ∪ B) and 5 is the only element of U which is not
an element of A ∪ B.
• AC = {2, 4, 5}, as by definition AC = U \ A, and these are the elements of U which are not elements
of A.
• B C = {1, 5}, as by definition B C = U \ B, and these are the elements of U which are not elements of
B.
• AC ∩ B C = {5}, because the only element in both AC and B C is 5 (see the above).