Solutions
Solutions
3. Find all strings over the alphabet {a, b, c, d} with length 2 and no repeated letter.
Solution : ab, ac, ad, ba, bc, bd, ca, cb, cd, da, db, dc
4. Find all strings over the alphabet {A, B, C} with length 3 and no AB, BC, or CA substring.
Solution : AAA, AAC, ACB, ACC, BAA, BAC, BBA, BBB, CBA, CBB, CCB, CCC
5. Find all strings over the alphabet {0, 1, 2} of length 4 that have 22 as a substring
Solution : First we find those with a longer substring of 2’s. The remaining ones have the form 22 ? ∗
or ?22? or ∗ ? 22 where ? 6= 2. We find the answer 2222, 0222, 1222, 2220, 2221, 2200, 2201, 2202, 2210,
2211, 2212, 0220, 0221, 1220, 1221, 0022, 0122, 1022, 1122, 2022, 2122.
V = {1, 2, 3, 4, 5, 6} and E = {{1, 3}, {1, 5}, {2, 6}, {3, 4}, {3, 5}, {5, 6}}.
Solution :
7. Find all graphs with vertex set {1, 2, 3, 4} that have {1, 2} and {3, 4} as edges, and have exactly two
more edges in addition to these.
Solution :
8. A restaurant has a special deal on a 3-course dinner consisting of an appetizer, an entree, and a dessert.
If there are 3 possible appetizers, 4 entrees, and 2 desserts, how many ways can you choose a different
dinner?
Solution : We use the rule of product. 3 options for the appetizer, 4 for the entree, and 2 for the
dessert gives us 3 · 4 · 2 = 24 different options for dinner.
1
MACM 201 Midterm 1 Practice Problems - Solutions
Solution : Note that the word has 2 H’s, 3 O’s, 3 M’s, 1 E, 1 R, 1 P, 1 I, and 1 S.
13
= 2! 13!
(a) 2,3,3,1,1,1,1,1 3! 3!
10 10!
(b) 2,3,1,1,1,1,1 = 2! 3!
2
MACM 201 Midterm 1 Practice Problems - Solutions
(c) We will obtain our arrangements by first choosing the ordering of the letters other than M, and
then selecting which spaces to insert an M. There are 10 letters other than M, and we can insert
an M at the beginning or end or anywhere in between. So, after choosing the other letters, there
are 11 possible places to insert an M. We have to insert 3 M’s and no two can go in the same place.
Therefore, for each arrangement of the other letters, there are 11 ways to insert 3 M’s so that no
3 11
10
two M’s are consecutive. In total we have the answer 2,3,1,1,1,1,1 3 = 2!10!3! 11
3 .
(a) How many ways are there to put the balls into the bins?
(b) How many are there if each bin must receive at most one ball?
Solution :
(a) There are k options for placing the first ball, k for the second, k for the third, and so on. This gives
us a total of k n arrangements.
(b) Since all the balls are to be placed in the bins then there are 0 ways to do this if there are more
balls than bins, i.e. n > k. In the case when n ≤ k there are k choices for placing the first ball,
k − 1 for the second, k − 2 for the third, on down to k − n + 1 for the last. This gives us a total of
k(k − 1) · · · (k − n + 1).
14. How many strings over the alphabet {A, B, C, D} of length 2n have the property that D does not appear
in any odd position?
Solution : We have 4 options for the letter in every even position and 3 options for every letter in an
odd position. By the rule of product there are 3n 4n = 12n such strings.
15. (a) How many permutations over {A, B, C, D, E, F, G, H} start with A and do not end with H?
(b) How many permutations over this alphabet start with a letter other than A and end with a letter
other than H?
Solution : (a) The first letter is fixed, there are 6 choices for the last letter (since we cannot have an
H). After this there are 6 choices for the second letter, 5, for the third, on down to 1 for the seventh.
This gives us a total of 6 · 6! strings satisfying the conditions.
(b) We begin by counting the total number of permutations not ending with H. In this case we have 7
choices of the last letter, then 7 choices for the first, 6 choices for the second, on down to 1 choice for
the seventh. This gives a total of 7 · 7! permutations not ending with H. By the first part, we know that
of the permutations not ending with H exactly 6 · 6! of them begin with A. Subtracting these gives us
a total of 7 · 7! − 6 · 6! permutations not beginning with A and not ending with H.
16. A club with 16 people must select a leadership committee with a president, secretary, and treasurer.
Assuming no person can have more than one such position, how many ways are there to select this
committee?
Solution : By the product rule there are 16 choices for president, 15 for secretary, and 14 for treasurer
for a total of 16 · 15 · 14.
3
MACM 201 Midterm 1 Practice Problems - Solutions
17. At a summer camp, the campers are divided into 10 cabins with 8 campers in each cabin. How many
ways are there to choose a set of 13 campers S with the property that 2 cabins have exactly 3 campers
in S, 3 cabins have exactly 2 campers in S, and 1 cabin has exactly 1 camper in S?
Solution : We begin by selecting how many campers will be chosen from each cabin. To do this we
will take our set of cabins, say {1, 2, . . . , 10} and divide it into a set S3 of size 2 (these cabins will send
3 campers), a set S2 of size 3 (these cabins will send 2 campers), a set S1 of size 1(this cabin will send
10
1 camper), and the rest. The number of ways to choose such a division is 2,3,1,4 . Once this division
has been selected, we need to choose 3 campers from each cabin in S3 (there are 83 ways to choose a
set of 3 campers from a cabin), we need to choose 2 campers from each cabin in S2 (there are 82 ways
to choose 2 campers from a cabin), and we need to choose 1 camper from the cabin in S1 . Putting all of
10
82 83 8
this together with the product rule gives us our answer, 2,3,1,4 3 2 1 .
18. How many ways are there to put 9 indistinguishable balls into four (distinguishable) containers num-
bered 1, 2, 3, 4 with the following added constraint:
Solution : Since the balls are indistinguishable, the only property of interest is how many balls a
given container has. If xi is the number of balls in container i, then (x1 , x2 , x3 , x4 ) is a sequence of
nonnegative integers with length 4 and sum 9: i.e. a solution to
x1 + x2 + x3 + x4 = 9 with xi ≥ 0.
x1 + x2 + x3 + x4 = 9 with xi ≥ 1.
y1 + y2 + y3 + y4 = 5 with yi ≥ 0.
4+5−1 8
The answer 5 = 5 .
(b) If container 1 has an odd number of balls, then we have x1 ∈ {1, 3, 5, 7, 9}. The remaining variables
then form a solution to x2 + x3 + x4 = 8, 6, 4, 2, or 0. So our answer is 8+2 6+2 4+2
+ 2+2
2 + 2 + 2 2 +
0+2
2 .
(c) There are 42 ways to choose which containers will have 0 balls. The 9 balls then have to be split
(1, 8), (2, 7), . . ., (8, 1) among the remaining containers. So in total the answer is 42 8.
19. A bookcase has four shelves and we wish to put 30 (distinguishable) books on these four shelves.
For this problem we consider two arrangements of the books to be the same only when they have
exactly the same books on each shelf in exactly the same order. Under these assumptions, how many
arrangements of the books are possible?
Solution : Name the books 1, 2, . . . , 30 and let Q be the set of strings over the alphabet {1, 2, . . . , 30, S}
that have exactly one occurrence of i for 1 ≤ i ≤ 30 and have exactly three occurrences of the letter
4
MACM 201 Midterm 1 Practice Problems - Solutions
S. Every Q ∈ Q has the form Q = Q1 SQ2 SQ3 SQ4 where Q1 , . . . , Q4 are substrings, and we associate
Q with the arrangement of books where Qi is the ordering of books appearing on shelf i. This gives a
correspondence between our arrangements and strings in Q so the number of arrangements of books
33
is |Q| = 3,1,1,...,1 = 33!
3! .
20. A binary string has k runs if it can be divided into k (but not more) substrings so that each substring
either has all entries 0 or all entries 1. For instance, the string 0011110100010111 has 8 runs since it
divides into the substrings
00 1111 0 1 000 1 0 111
How many binary strings of length n have exactly k runs?
Solution : A binary string of length n with k runs that starts with 0 is characterized by a sequence of
positive integers (x1 , . . . , xk ) with sum n, where xi is the length of the ith run. Setting yi = xi − 1 gives
us a sequence (y1 , . . . , yk ) of nonnegative integers with sum n − k. Therefore, the number of binary
strings of length n with k runs starting with a 0 is equal to the number of sequences of nonnegative
integers with length k and sum n − k, which is n−1 k−1 (i.e. the number of solutions to y1 + . . . + yk = n − k
with yi ≥ 0). The number of strings with k blocks starting with 1 is the same as the number starting
n−1
with 0, so the total number of binary strings of length n with k runs is 2 k−1 .
Alternate Solution: For the example given in the question we can represent it in terms of stars ‘ * ’
and bars ‘ | ’:
∗∗ | ∗ ∗ ∗ ∗ | ∗ | ∗ | ∗ ∗ ∗ | ∗ | ∗ | ∗ ∗∗
This pattern would also represent the binary string in which all the 0’s and 1’s were switched - which
is still a string with k runs but only now it begins with 1. So this pattern represents two different
binary strings of length n with a run of k - the one that starts with 0 and the one that starts with 1. In
general, a binary string of length n with k runs that starts with 0 is characterized by a string of length
n in k − 1 characters ‘ ∗ | ’ and n − k + 1 characters ‘ * ‘, where the string must end in a ‘ * ‘. That is, it
is of the form
... ∗
where the n − 1 remaining spaces must be filled in with exactly k − 1 characters ‘ ∗ | ’ and exactly n − k
characters ‘ * ‘. This can be done in n−1
k−1 ways. But this is also the number of binary strings of length
n−1
n with k runs that start with 1. Therefore, the total number of such strings is 2 k−1 .
21. How many binary strings of length n have exactly one occurrence of the substring 10?
Solution : Such a string has an initial substring S1 of 0’s of length ≥ 0 followed by a substring S1
of 1’s of length ≥ 1 then a substring S3 of 0’s of length ≥ 1 and then a substring S4 of 1’s of length
≥ 0. Setting xi to be the length of Si we have a correspondence between strings with exactly one
10 substring and integer sequences (x1 , . . . , x4 ) with sum n and x1 , x4 ≥ 0, x2 , x3 ≥ 1. Now setting
x02 = x2 − 1 and x03 = x3 − 1 gives us a sequence of nonnegative integers (x1 , x02 , x03 , x4 ) with length
4 and sum n − 2. We conclude that the number of strings with exactly one 10 substring is equal to
(n−2)+4−1 n+1 n+1
n−2 = n−2 = 3 .
x1 + x2 + x3 + x4 + x5 = 30.
For each part below, determine how many solutions there are to the above equation satisfying the
additional constraint.
5
MACM 201 Midterm 1 Practice Problems - Solutions
Solution :
6
MACM 201 Midterm 1 Practice Problems - Solutions
(d) No, G is not bipartite since it contains a cycle of odd length (2 − 5 − 6 − 2). If a bipartite graph has a
cycle then it must be of even length since it must alternate vertices from V1 and V2 and have an equal
number from each set.
Solution :
(a)
7
MACM 201 Midterm 1 Practice Problems - Solutions
(b)
(c)
27. Draw two non-isomorphic graphs with 6 vertices where each vertex has degree 2.
Solution : The graph which is a cycle of length 6, and the graph with two triangles (cycles of length
3).
28. Let n ≥ 3 and let Pn be a graph with vertex set {x1 , . . . , xn } ∪ {y1 , . . . , yn } and the following edges:
Solution :
(a)
8
MACM 201 Midterm 1 Practice Problems - Solutions
(b) There are n edges incident to two vertices in {x1 , . . . , xn }, there are n edges incident to two vertices
in {y1 , . . . , yn }, and there are n edges of the form {xi , yi } with one end in each set. This gives a
total of 3n edges in the graph Pn .
(c) There are 2n vertices, so there are 2n choices for the middle vertex of the 2 edge (and 3 vertex)
path. After choosing the middle vertex, we have to choose two of the three edges incident with this
vertex to form our path. This can be done in 3 way. We conclude that Pn has 6n paths of length 2.
(d) The only cycles of length four in this graph contain an edge with both ends in {x1 , . . . , xn }, say
{xi , xi+1 } and the corresponding edge {yi , yi+1 } with both ends in {y1 , . . . , yn }. It follows that the
number of cycles of length 4 in Pn is n.
29. Let n ≥ 4 and let Rn be a graph with vertex set {x1 , . . . , xn } ∪ {y, y 0 } and the following edges:
Solution :
(a)
(b) There are n edges incident with two vertices in {x1 , . . . , xn }, there are n incident with y and n
incident with y 0 . This gives a total of 3n edges in the graph Rn .
(c) First we consider subgraphs isomorphic to K4− containing both y and y 0 . Such a subgraph must
then contain two vertices in {x1 , . . . , xn } that are adjacent (since there is no edge between y and
y 0 in Rn , this must be the missing edge in the K4− ). There are n ways to choose a pair of adjacent
vertices in {x1 , . . . , xn } so there are n subgraphs of Rn isomorphic to K4− containing both y and y 0 .
Next we count subgraphs isomorphic to K4− that contain y but not y 0 . Since n ≥ 4 there does
not exist a subset S ⊆ {x1 , . . . , xn } with |S| = 3 so that all three 2 element subsets of S edges.
Therefore, every K4− subgraph containing y but not y 0 must consist of a 3 vertex (2-edge) path
with all vertices in {x1 , . . . , xn } together with all edges between this path and y. There are n ways
to choose a 3 vertex path with all vertices in {x1 , . . . , xn } so there are n subgraphs isomorphic to
K4− containing y but not y 0 .
A similar analysis to that above shows that there are n subgraphs isomorphic to K4− containing y 0
and not y. It follows that the total number of subgraphs of Rn isomorphic to K4− is 3n.
9
MACM 201 Midterm 1 Practice Problems - Solutions
(d) We will consider the various possible paths of length 3 (3 edges and 4 vertices) and divide into
cases depending on their behaviour relative to the two special vertices y and y 0 . First we count
the paths not containing y or y 0 . In this case the path must be contained in the cycle on the xi
vertices. There are n ways to choose the middle edge of this path, and just one way to complete it.
So there are n paths of length 3 not containing y or y 0 .
Next we will count paths of length 3 containing exactly one of y, y 0 . Let us consider those that
contain y but not y 0 . If they have y at the end, then we may construct them starting from y. After
y, there are n ways to choose the second vertex and then 2 ways to choose the third and just 1 for
the fourth. This gives us 2n paths of this type. If y is in the middle of the path, then we need to
choose the other “middle” vertex xi and this can be done in n ways. There are 2 choices for the
other vertex of our path adjacent to xi , and now there are n − 2 ways to choose the remaining
vertex of our path that will be adjacent to y. This gives us a total of 2n(n − 2) paths of this
type. A similar argument for paths containing y 0 but not y shows that the total number of paths
containing exactly one of y, y 0 is 4n + 4n(n − 2).
Finally, we count the paths of length 3 containing both y and y 0 . If y and y 0 are both ends of the
path, then there are n ways to choose the middle edge, and 2 ways to connect this middle edge to y
and y 0 (the lower index x-vertex connects either to y or to y 0 . Therefore, there are 2n paths ending
in y and y 0 . Next suppose that y is an end and y 0 is not. In this case there are n choices for the
vertex in between y and y 0 on the path and n − 1 choices for the remaining vertices for a total of
n(n − 1). Reversing the role of y and y 0 gives another n(n − 1) paths. So, in total, the number of
paths of length 3 containing both y and y 0 is 2n + 2n(n − 1).
Summing over all of our cases we find that the total number of paths of length 3 in Rn is given by
the formula (note that in this class you need not simplify computations).
Alternate Solution:
For a path of length 3 we focus on the middle edge. This edge will fall into one of three cases.
(It will be helpful it you draw pictures in each case.)
Case 1: The middle edge is of the form {xi , xi+1 } (if i = n then think of i + 1 as 1), and there are
n choices for this edge. Once this edge is chosen, there are 3 choices for the edge off of xi and an-
other 3 choices for the edge off of xi+1 . Of these 9 choices of “end” edges we need to avoid 2 which
result in triangles, namely yxi xi+1 y and y 0 xi xi+1 y 0 . Therefore, there are 7n such paths in this case.
Case 2: The middle edge is of the form {y, xi }, there are n choices for this edge. The possible paths
in this case are: (i) xk yxi xi−1 or (ii) xk yxi xi+1 (in each case there are n − 2 choices for xk ), or (iii)
xk yxi y 0 (where there is n − 1 choices for xk ). Hence there are 2n(n − 2) + n(n − 1) paths in this case.
Case 3: The middle edge is of the form {y 0 , xi }. This is similar to case 2, there are 2n(n−2)+n(n−1)
paths.
10
MACM 201 Midterm 1 Practice Problems - Solutions
30. Let G be a graph with m edges and the property that every vertex is adjacent to d other vertices. If G
has no cycle of length 3, how many 4 vertex paths does G have? Hint: try choosing the middle edge.
Solution : There are m choices for the middle edge of our 4 vertex (and 3 edge) path. Once the middle
edge, say {v, w}, has been chosen we need to select a different edge incident with v (there are d − 1
ways to do this) and a different edge incident with w (in d − 1 ways) to form our path. Since G has no
cycle of length 3, however we choose these different edges will give a 4 vertex path. It follows that the
number of 4 vertex paths is equal to m(d − 1)2 .
31. For positive integers a, b we let Ga,b be a graph with vertex set consisting of all ordered pairs of integers
(x, y) with 1 ≤ x ≤ a and 1 ≤ y ≤ b, and edge set consisting of the following:
Draw the graph G3,4 . Determine for all a, b how many cycles of length 6 there are in Ga,b .
Solution : The graph G3,4 is drawn below. Call an edge e outer if e = {(1, y), (1, y + 1)} or e =
{(a, y), (a, y + 1)} for some y or if e = {(x, 1), (x + 1, 1)} or e = {(x, b), (x + 1, b)} for some x. An edge e is
inner if it is not outer. Observe that in the figure below the outer edges form the outer rectangle and
the inner edges are inside. A similar drawing of Ga,b will have the same feature. If we consider this
more general drawing of Ga,b we see that each cycle of length 6 will have one inner edge inside and
the rest of the graph outside. It follows that the number of cycles of length 6 is precisely the number
of inner edges. The inner edges consist of vertical edges that make up a − 2 paths of length b − 1 and
horizontal edges that make up b − 2 paths of length a − 1. It follows that the total number of cycles of
length 6 is equal to (a − 2)(b − 1) + (b − 2)(a − 1).
32. Let 2 ≤ b ≤ a ≤ n. Define Ka−b to be a graph obtained from Ka by choosing b vertices and deleting all
edges between chosen vertices. How many subgraphs of Kn are isomorphic to Ka−b ?
Solution : To select Ka−b from our complete graph Kn , we first choose a subset of vertices A with
|A| = a and then we choose B ⊆ A with |B| = b. These choices select the Ka−b subgraph with vertex set
A and −b
n a
edges missing
n
between vertices in B. We deduce that the number of Ka subgraphs is equal to
a b = a−b,b,n−a .
33. If two integers are selected, at random and without replacement, from {1, 2, 3, . . . , 100}, what is the
probability their sum is even?
Solution : S = {{x, y} : x, y ∈ {1, 2, . . . , 100}, x 6= y}
A = {{x, y} ∈ S : x + y is even } = {{x, y} ∈ S : x + y both even } ∪ {{x, y} ∈ S : x + y both odd}
11
MACM 201 Midterm 1 Practice Problems - Solutions
100 50 50 50
|S| = 2 and |A| = 2 + 2 =2 2
50
2 2 2(50)(49) 49
P r(A) = 100
= 100(99) = 99 .
2
Alternate solution (ordered pairs):
S = {(x, y) : x, y ∈ {1, 2, . . . , 100}, x 6= y}
A = {(x, y) ∈ S : x + y is even }
|S| = 100 ∗ 99 and |A| = 100 ∗ 49
100(49) 49
P r(A) = 100(99) = 99 .
34. If two binary strings, x and y, of length n are selected, at random and without replacement, what is
the probability that the total number of ones in x and y combined is even?
Solution : S = {{x, y} : x 6= y are binary strings of length n}
A = {{x, y} ∈ S : number of ones in x and y combined is even}
n
|S| = 22 and |A| = 2n (2n−1 − 1)/2 (since x 6= y and the first n − 1 bits of y determine the nth bit)
2n (2n−1 − 1)/2 2n (2n−1 −1) 2n−1 −1
P r(A) = 2n
= 2n (2n −1) = 2n −1 .
2
35. What is the minimum number of times we must toss a fair coin so that the probability of getting two
or more heads is at least 0.8?
Solution : Consider tossing a coin n times. Let A0 be the event of getting 0 heads, and A1 the event of
1 n
getting 1 head. Then P r(A0 ) = n and P r(A1 ) = n . The event A0 ∪ A1 is the set of all outcomes with
2 2
0 or 1 heads, so we want to determine P r(A0 ∪ A1 ). Since A0 ∩ A1 = ∅,
1 n 2n − 1 − n
P r(A0 ∪ A1 ) = 1 − P r(A0 ∪ A1 ) = 1 − P r(A0 ) − P r(A1 ) = 1 − − = .
2n 2n 2n
Now, we want to know the values for n for which this probability is at least 0.8.
2n − 1 − n
≥ 0.8
2n
2n+1 ≥ 10 + 10n
12
MACM 201 Midterm 1 Practice Problems - Solutions
36. Using the axioms of probability (and any theorems we proved in class from these axioms if needed),
prove that P r(∅) = 0.
Solution : Since S = ∅ ∪ S is a disjoint union, then by axiom 3
P r(S) = P r(∅) + P r(S) and by axiom 2, 1 = P r(∅) + 1, therefore P r(∅) = 0.
37. There are two boxes. The first contains two green balls and seven red balls; the second contains four
green balls and three red balls. Alice selects a ball by first choosing one of the two boxes at random.
She then selects one of the balls in this box at random. If Alice has selected a red ball, what is the
probability that she selected a ball from the first box?
Solution : Let S be the set of all ways to select a box and a ball. Let A be the event that a ball was
selected from the first box, then A is the event that a ball was selected from the second box. Let B be
the event that a red ball was selected.
We wish to determine P r(A|B). By Bayes’ theorem
P r(B|A)P r(A)
P r(A|B) =
P r(B)
We will determine each of the probabilities in the right-hand side of this expression.
P r(A) = 1/2
P r(B|A) = 7/9
P r(B) = P r(A)P r(B|A) + P r(A)P r(B|A) = (1/2)(7/9) + (1/2)(3/7) = 38/63
Therefore,
38. There are two bags. The first contains two green balls and seven red balls; the second contains four
green balls and three red balls. Bob reaches in and selects one ball from the first bag and places it in
the second bag. Then Alice selects one ball from the second bag.
Solution : Let B be the event that Bob selected a red ball from the first bag. Let A be the event that
Alice selected a red ball from the second bag. Initially we know the following probabilities:
We also have two cases to consider, depending on whether Bob pulled a red or a green ball from the
first bag. If he pulled out a red ball, then after placing the ball in the second bag it would have 4 green
13
MACM 201 Midterm 1 Practice Problems - Solutions
and 4 red balls. On the other hand, if Bob pulled a green ball from the first bag then the second bag
would have 5 green and 3 red balls. This means we can compute P r(A|B) and P r(A|B), to find P r(A).
(a) We want to know P r(A), so by the law of total probability,
P r(A) = P r(B)P r(A|B) + P r(B)P r(A|B)
= (7/9)(4/8) + (2/9)(3/8)
= 34/72 ≈ 0.472
P r(A|B)P r(B)
P r(B|A) =
P r(A)
P r(A|B)P r(B)
=
P r(B)P r(A|B) + P r(B)P r(A|B)
(4/8)(7/9)
=
(7/9)(4/8) + (2/9)(3/8)
28/72
= = 28/34 = 14/17 ≈ 0.82
34/72
(a) If a cyclist is taking Z the probability that they test positive is 0.99.
(b) If they are not taking Z the probability that they test positive is 0.05.
Question: If a randomly chosen cyclist tests positive for Z, what is the probability they are taking
steroid Z?
We showed in class that the probability is 0.6875 which is very low. This is because the probability 0.05
in property 2 is high. A person who satisfies property 2 is called a false positive. Redo the calculation
using 0.01 instead of 0.05 for property 2.
Solution : In the class notes we let
S be the set of all Olympic cyclists
A be the set of Olympic cyclists taking Z
B be the set of cyclists which test positive.
We are given P r(A) = 0.1, P r(B|A) = 0.99 and P r(B|A) = 0.01. Since
P r(B) = P r(A)P r(B|A) + P r(A)P r(B|A)
then from Baye’s Theorem we have
P r(B|A)P r(A) P r(B|A)P r(A) (0.99)(0.1)
P r(A|B) = = = = 0.9166
P r(B) P r(A)P r(B|A) + P r(A)P r(B|A) (0.1)(0.99) + (0.9)(0.01)
A cyclist that tests positive is 91.7% likely to be taking Z. This is higher than what we previously got
but still not high enough to be considered certain.
14
MACM 201 Midterm 1 Practice Problems - Solutions
40. Jar A has 800 red candies and jar B has 600 green candies. If we do the following...
1. Move one cup of red candies from jar A to jar B and mix.
2. Move one cup of mixed candies from jar B to jar A and mix.
3. Move one cup of candies from each of jar A and jar B to the bowl and mix.
4. Randomly select one candy from the bowl.
Solution : Here we assume ”a cup“ is just some fixed number of candies (say y candies).
As a result of mixing (steps 1 and 2) there will be x red candies that moved to the green jar and x green
candies that moved to the red jar (this does not depend on the size of the cup). Prior to step 3, the jars
consist of the following
# of red # of green
red jar 800 − x x
green jar x 600 − x
When step 3 is done, the number of reds moving to the dish (assuming y candies in a cup) is:
(800 − x) x 2400 + x
y+ y= y
800 600 2400
The proportion of reds in the dish is this number divided by 2y, so the probability of selecting a red
from the dish is
2400 + x 1 x
= + > 1/2.
2 · 2400 2 4800
Therefore, it is more likely to select a red candy from the dish.
41. Suppose that m (distinguishable) balls are thrown in n (distinguishable) bins. What is the expected
number of bins with exactly 1 ball?
Solution : We can use the ideas/formula from the notes. The probability that bin i has 1 ball is
m−1
m n1 1 − n1 . Let X be the number of bins that have exactly 1 ball, and set Xi for 1 ≤ i ≤ n to be the
random
P variable that takes on 1 if bin i has 1 ball and 0 if bin i does not have exactly 1 ball. Clearly
X = i Xi . Then
m−1
E(Xi ) = 0P r(Xi = 0) + 1P r(Xi = 1) = m n1 1 − n1
and
1 m−1
X
E(Xi ) = nm n1 1 −
E(X) = n .
i
42. Suppose we roll a biased six sided dice. Rolling a 1, 2, 3, 4 or 5 are equally likely, and rolling a 6 is twice
as likely as each of the other values. If we roll the dice 49 times, let X be the random variable for the
number of 6’s that appear.
15
MACM 201 Midterm 1 Practice Problems - Solutions
Solution : The probability of rolling a 6 is p = 2/7 and the probability of rolling each of the other
values is 1/7.
2 k 5 49−k
(a) P r(X = k) = 49
k 7 7
(b) Since the random variable X is binomially distributed then E(x) = np = 49(2/7) = 14.
k−1 2
(c) Let Y be the number of rolls until the first 6 appears. Then P r(Y = k) = 75 7 , is a geometric
distribution. Therefore,
1 7
E(Y ) = = = 3.5
p 2
43. A program is designed to generate binary strings of any length such that in any position a 1 is three
times as likely to appear than a 0. What is the probability that a string of length 10 contains at least
eight 0’s. (Reduce your answer to a fraction: a/b.)
Solution : In any particular spot in the string, the probability that a 0 appears is p = 1/4 and the
probability that a 1 appears is q = 3/4. Let X be the random variable that counts the number of 0’s.
Then
44. How many times would we expect to roll a 4-sided (fair) die (also called a tetrahedral die) to get all 4
outcomes to appear.
Solution : This is the coupon collector problem with n = 4 so we would expect to roll the die
1 1 1 25 25 1
nHn = 4 1 + + + =4 = =6+
2 3 4 12 3 3
45. A bin contains five balls numbered 1,2,3,4, and 5. When two balls are drawn (without replacement)
from the bin, the random variable X records the higher value. Find E(X).
Solution : The probability distribution for X is:
16
MACM 201 Midterm 1 Practice Problems - Solutions
P r(X = 1) = 0,
1
1 1
P r(X = 2) = 5
=
2
10
2
1 2
P r(X = 3) = 5
=
2
10
3
1 3
P r(X = 4) = 5
=
2
10
4
1 4
P r(X = 5) = 5
=
2
10
Therefore,
46. A carnival game costs $3 to play. The player selects one card from a standard deck of 52 cards. If the
player selects an ace or king the player wins $8. If the player selects a four or seven the players wins
$4. Otherwise the player loses their $3. What is the expected amount the player will win?
Solution : Recall, a standard deck of playing cards has 4 cards of each rank (one of each suit). Let X
be the amount of money won in playing the game once.
P r(X = 8) = P r( getting an Ace or King) = 4+4
52 = 13
2
4+4 2
P r(X = 4) = P r( getting an Ace or King) = 52 = 13
52−16 9
P r(X = −3) = P r( getting any other card) = 52 = 13
16 8 27 −3
E(X) = 8 · P r(X = 8) + 4 · P r(X = 4) + (−3) · P r(X = −3) = 13 + 13 − 13 = 13
3
Therefore, on average a player losses $ 13 ≈ 23 cents.
17