Back

Solution: 2019 Fall Midterm - 5

Author: Michiel Smid

Question

Consider strings of length 4 over the alphabet $\{a,b,c,d\}$. How many such strings are there that start with $ad$ or end with $dcb$?
(a)
17
(b)
20
(c)
18
(d)
19

Solution

  1. Determine A

    Let A be the event that a 4 letter string starts with $ad$

    The first 2 letters are locked in place: 1 possibility

    The last 2 letters can be a, b, c or d: $4^2$ possibilities

    $|A| = 1 \cdot 4^2 = 16$

  2. Determine B

    Let be the event that a 4 letter string ends with $dcb$

    The last 3 letters are locked in place: 1 possibility

    The first letter can be a or d: $4^1$ possibilities

    $|B| = 1 \cdot 4^1 = 4$

  3. Determine $A \cap B$

    Let A and B be the event that a 4 letter string starts with $ad$ and ends with $dcb$

    The first 2 letters are locked in place: 1 possibility

    The last 3 letters are locked in place: 1 possibility

    $|A \cap B| = 1 \cdot 1 = 1$

  4. Profit

    $A \cup B = |A| + |B| - |A \cap B|$

    $A \cup B = 16 + 4 - 1 $

    $A \cup B = 19$