Seeking help understanding a step in an argument for counting ternary strings

127 Views Asked by At

Problem: How many ternary strings (using 0's, 1's and 2's) of length 8 either start with a 1, end with two 0's or have 4th and 5th positions 12?

Given solution: Let $A_1$ denote the set of ternary strings of length 8 which start with a 1, $A_2$ denote the set of ternary strings of length 8 which end with two 0's, and $A_3$ denote the set of ternary strings of length 8 which have 4th and 5th positions 12. By the general rule of inclusion/exclusion our answer is $$3^7 + 3^6 + 3^6 − 3^5 − 3^5 − 3^4 + 3^3.$$

I can not understand the last part that why people are deducting and adding. Can someone please kindly help me on this?

1

There are 1 best solutions below

1
On

We wish to find $$\left| \cup_{i \in \{1,2,3\}} A_i \right|$$ In this particular case, Inclusion-Exclusion implies this is given by: $$|A_1|+|A_2|+|A_3|-|A_1 \cap A_2|-|A_1 \cap A_3|-|A_2 \cap A_3|+|A_1 \cap A_2 \cap A_3|$$ which correspond to the numbers in the formula $$3^7 + 3^6 + 3^6 − 3^5 − 3^5 − 3^4 + 3^3$$ by individual counting arguments. (E.g. $|A_1 \cap A_2|$ is the number of ternary strings of length 8 which start with a 1 and end in two 0's; so there's $3^5$ of them.)

(Note: Inclusion-Exclusion is Theorem 1 in the UND notes; this is the $n=3$ case.)