Sub topic 13
Counting Subsets and the Power Set
This chapter assumes you know set notation, the meaning of "subset" and "proper subset", the empty set, and the basic operations from the earlier chapters. You also need basic combinations, written C(n, k) or "n choose k", which is the number of ways to pick k items from n when order does not matter.
CAT questions on subsets are usually short. They ask how many subsets a set has, how many satisfy some condition, or how many pairs of sets fit a rule. Almost all of them come from one idea: for each element, decide whether it is in the subset or not.
The core idea: in or out
Take a set S with n elements. To build a subset, go through the elements one at a time. For each one you choose "in" or "out". The choices are independent, so the total number of subsets is
2 × 2 × ... × 2 (n times) = 2^n
The set of all subsets of S is called the power set of S, written P(S). It always has 2^n members. Each member of P(S) is itself a set, so the power set is a set of sets.
The tree has 2 × 2 = 4 leaves, one per subset. The empty set is the branch where every element is "out". The set S itself is the branch where every element is "in". Both count as subsets.
Subset counts you should know
For a set with n distinct elements:
| Quantity | Count | Reason |
|---|---|---|
| All subsets | 2^n | Each element is in or out |
| Proper subsets (all except S itself) | 2^n − 1 | Remove the one subset equal to S |
| Non-empty subsets | 2^n − 1 | Remove the empty set |
| Non-empty proper subsets | 2^n − 2 | Remove both S and the empty set |
| Subsets with exactly k elements | C(n, k) | Choose which k elements are in |
The last row connects to the first. Every subset has some size from 0 to n, so adding the counts for each size must give the total:
C(n, 0) + C(n, 1) + ... + C(n, n) = 2^n
For n = 4 the sizes 0 to 4 give the counts below.
| Size k | 0 | 1 | 2 | 3 | 4 | Total |
|---|---|---|---|---|---|---|
| Subsets C(4, k) | 1 | 4 | 6 | 4 | 1 | 16 |
The total is 16, which equals 2^4.
Generating and checking counts in Python
The code below builds the power set of {1, 2, 3} by size, which matches the table above.
from itertools import combinations
def power_set(items):
items = sorted(items)
return [c for k in range(len(items) + 1) for c in combinations(items, k)]
subsets = power_set({1, 2, 3})
print(len(subsets)) # 8
for s in subsets:
print(s)
# ()
# (1,)
# (2,)
# (3,)
# (1, 2)
# (1, 3)
# (2, 3)
# (1, 2, 3)The first line printed is (), the empty subset. The last is the full set. Both are in the count of 8.
Fixing or forbidding elements
Most exam variations add a condition on specific elements. The method is the same each time. Fix the choice for the constrained elements, then count the free choices for the rest.
If k particular elements must be in the subset, those k choices are forced. The other n − k elements are free, so the count is 2^(n−k).
If k particular elements must be out, the count is also 2^(n−k).
"At least one" conditions are easiest by complement. Count all subsets, then subtract those that break the condition.
Example 1. How many subsets of {1, 2, ..., 8} contain at least one even number?
There are 2^8 = 256 subsets in total. A subset with no even number uses only the four odd elements 1, 3, 5, 7, so there are 2^4 = 16 of them. The answer is 256 − 16 = 240.
Example 2. How many subsets of {1, 2, ..., 6} have 3 as their smallest element?
The subset must contain 3. It must not contain 1 or 2. The elements 4, 5, 6 are free. The count is 2^3 = 8.
Example 3. How many subsets of a 10-element set contain both x and y but not z?
Three elements are fixed. Seven remain free, so the count is 2^7 = 128.
The next block checks several of these rules for n = 5.
from math import comb
n = 5
print(2**n, 2**n - 1, 2**n - 2) # 32 31 30 (all, proper, non-empty proper)
print(comb(n, 2)) # 10 (subsets of size 2)
print(2**(n - 1)) # 16 (must contain one given element)
print(2**(n - 2)) # 8 (must contain two given elements)
print(2**n - 2**(n - 2)) # 24 (contain at least one of two given elements)The last line uses the complement. Subsets containing neither given element number 2^(n−2) = 8, and 32 − 8 = 24.
Subsets by size and parity
Sometimes the condition is on the size of the subset, not on which elements it contains.
- The number of subsets of size exactly k is C(n, k).
- The number of subsets of size at least k is the sum of C(n, j) for j from k to n. For small k it is often faster to subtract the sizes below k from 2^n.
- For n ≥ 1, half of all subsets have an even number of elements and half have an odd number. Each count is 2^(n−1).
The parity fact comes from pairing. Pick one element and toggle it in or out of any subset. This switches the subset's size between even and odd, so subsets pair up with one even and one odd partner each.
Example 4. How many subsets of {1, 2, ..., 7} have an odd number of elements?
2^(7−1) = 64.
Example 5. How many subsets of a 6-element set have at least 2 elements?
Subtract sizes 0 and 1: 2^6 − C(6, 0) − C(6, 1) = 64 − 1 − 6 = 57.
Pairs of sets and nested subsets
Occasionally CAT asks about pairs of subsets. The in-or-out method still works, but now each element has more than two states.
For pairs (A, B) with A ⊆ B ⊆ S, each element falls in one of three states: not in B (so not in A), in B but not in A, or in both. That gives 3 choices per element and 3^n pairs.
For ordered pairs of arbitrary subsets (A, B) of S, each element has four states: in neither, only A, only B, or both. That gives 4^n pairs, which equals (2^n)².
For splitting S into two labelled groups, such as Team 1 and Team 2, each element goes to one of two groups, giving 2^n splits. If the groups are unlabelled and both must be non-empty, divide the labelled count by 2 after removing the two splits where one group is empty: (2^n − 2) / 2 = 2^(n−1) − 1.
The code below confirms the 3^n rule by brute force for n = 4. It represents each subset as a bitmask.
n = 4
masks = range(2**n)
count = sum(1 for a in masks for b in masks if a & b == a) # A is a subset of B
print(count, 3**n) # 81 81Traps and consistency checks
Watch for these points in exam wording:
- Empty set and full set. "Subsets" includes both. "Proper subsets" removes S. "Non-empty proper subsets" removes both. Read the exact phrase.
- Order does not matter. {1, 2} and {2, 1} are the same subset. If order matters, you are counting arrangements, not subsets.
- Elements that are sets. If S = {1, {2, 3}}, it has 2 elements, so 4 subsets. The inner set {2, 3} counts as a single element.
- Large n. Express answers as powers of 2 when n is large, such as 2^20, instead of expanding. Answer options often use this form.
- Quick sanity check. The answer to a "how many subsets satisfy..." question must be at most 2^n and at least 0. If you subtract a bad count, it must be no larger than the total.
Link to the earlier chapters
Counting subsets of a universal set uses the same complement idea as counting "neither". The count of subsets avoiding a condition is subtracted from the total, just as the "neither" group is subtracted from the total in a Venn problem. Each of the eight regions in a three-set Venn diagram is also a choice of in or out for three sets, which is why there are 2^3 = 8 regions.
Exercise
A set has 7 elements. (a) How many non-empty proper subsets does it have? (b) How many of its subsets contain a particular element p but not a particular element q?
Show answer
(a) 2^7 − 2 = 128 − 2 = 126. (b) Two elements are fixed (p in, q out), and the other 5 are free, so 2^5 = 32.
Exercise
How many subsets of {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} contain at least one of the numbers 1, 2, 3, and have an even number of elements?
Show answer
First count all even-sized subsets: 2^9 = 512. Now remove the even-sized subsets that contain none of 1, 2, 3. These use only the 7 elements 4 to 10, and half of the 2^7 = 128 subsets of those have even size, so 2^6 = 64. The answer is 512 − 64 = 448.
Exercise
A set S has 6 elements. How many ordered pairs (A, B) of subsets satisfy A ⊆ B ⊆ S?
Show answer
Each element has 3 states: outside B, in B but not A, or in both A and B. The count is 3^6 = 729.