0% found this document useful (0 votes)
20 views17 pages

Solutions

Uploaded by

Agrim joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views17 pages

Solutions

Uploaded by

Agrim joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

MACM 201 Midterm 1 Practice Problems - Solutions

1. List all strings of length 2 over the alphabet {X, Y, Z}.


Solution : XX, XY , XZ, Y X, Y Y , Y Z, ZX, ZY , ZZ

2. Find all permutations over {P, Q, R}


Solution : P QR, P RQ, QP R, QRP , RP Q, RQP

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.

6. Draw the graph G = (V, E) given by

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

9. Consider the word TUMULTUOUS.

(a) How many ways are there to arrange these letters?


(b) How many arrangements have the substring SUM?
(c) How many arrangements have the substring TOT?
(d) How many have both SUM and TOT?

Solution : Note that this word has 2 T’s, 4 U’s, 1 M, 1 L, 1 O, and 1 S.


10

(a) 4,2,1,1,1,1
(b) We can treat SUM as a single symbol, say X. This is then equivalent to arranging 2 T’s, 3 U’s, 1 L,
8
1 O, and 1X. So our answer is 2,3,1,1,1 .
(c) We can treat TOT as a single symbol, say Y. This is then equivalent to arranging 4 U’s, 1 M, 1 L,
8
1 S, and 1Y. So our answer is 4,1,1,1,1 .
(d) Treating SUM as X and TOT as Y our problem is the same as arranging 3 U’s 1 L, 1X, and 1Y.
6
Therefore the answer is 3,1,1,1 .

10. Determine the coefficient of x10 y 40 the expansion of (2x − 3y)50 .


Solution : By the binomial theorem, this coefficient is 50
 10 40
10 2 (−3) .

11. Consider the expression f = (x + y − 3z)5 .

(a) Find the coefficient of x2 yz 2 in the expression of f .


(b) How many terms are there in the expansion of f ?
(c) What is the sum of all the coefficients in the expansion of f .
5 5!
(−3)2 = 9 ·

Solution : (a) By the multinomial theorem, the coefficient is 2,1,2 2!2! = 270.
(b) The number
 of 7terms is
 the number of integer triples k1 , k2 , k3 such that k1 + k2 + k3 = 5 and ki ≥ 0.
This is 3+5−1 7 7·6

5 = 5 = 2 = 2 = 21.
(c) The sum of all the coefficients is obtained by substituting x = y = z = 1 into f . This is (1 + 1 − 3)5 =
−1.

12. Consider the word HOMEOMORPHISM.

(a) How many ways can you arrange these letters?


(b) If we omit all three copies of M, leaving HOEOORPHIS, how many ways are there to arrange
these remaining letters?
(c) How many ways can you arrange the letters so that no two M’s are consecutive?
Hint: start by arranging the letters other than M using your answer to part (12b), then choose the
positions in which to insert the three M’s.

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 .

13. There are n balls labelled 1, . . . , n and k bins labelled 1, . . . , k.

(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:

(a) Every container has at least one ball.


(b) Container 1 has an odd number of balls.
(c) Exactly two containers have 0 balls.

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.

We will use this observation repeatedly.

(a) In this case we are counting the number of solutions to

x1 + x2 + x3 + x4 = 9 with xi ≥ 1.

Setting yi = xi − 1 we have that (y1 , . . . , y4 ) is a solution to

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 .

22. Consider the following equation where x1 , . . . , x5 are integer variables

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

(a) xi ≥ 0 for all 1 ≤ i ≤ 5


(b) xi ≥ −2 for all 1 ≤ i ≤ 5
(c) xi ≥ i for 1 ≤ i ≤ 5
Solution : In each case we reduce to counting sequences of nonnegative integers with a fixed sum.
(a) This is precisely the number of sequences of nonnegative integers with length 5 and sum 30 which
is 30+4
4 .
(b) Setting yi = xi + 2 gives a sequence of nonnegative integers (y1 , . . . , y5 ) with sum 40 so the number
40+4

of solutions is 4 .
(c) Setting zi = xi − i gives a sequence of nonnegative integers (z1 , . . . , z5 ) with sum 15 so the number
of solutions is 15+4

4 .

23. Consider the graph in the figure below.


(a) Find all subgraphs that are cycles.
(b) Find the subgraph induced by the vertices {1, 3, 4, 6}.
(c) Find all spanning subgraphs that are paths.
(d) Is G bipartite? If yes, draw a bipartition of G otherwise explain.

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.

24. How many subgraphs of Kn are isomorphic to the graph ?


Solution : Consider dividing the vertex set of Kn into a set S1 of size 1, a set S2 of size 1, a set S3 of
size 2, and a set S4 with the remaining n − 4 vertices. Now add edges between S1 and S2 and between
S2 and S3 and add an edge between the two vertices in S3 . This construction gives us a subgraph of the
desired type. Moreover this gives us a correspondence thus proving that the number of such subgraphs
n

is equal to 1,1,2,n−4 .
A Second Solution: First choose a vertex from Kn which will be the vertex incident with a single
edge, then choose a vertex from Kn which will be the vertex in the triangle adjacent to the first vertex.
Finally
 choose
 n−2the remaining two vertices. Therefore the number of such choices (and hence subgraphs)
is n1 n−1
1 2 .
A Third Solution: Pick an ordered 4-tuple from the vertices of Kn , say (v1 , v2 , v3 , v4 ). These will be
n(n−1)(n−2)(n−3)
the vertices in . The number of such choices for the vi ’s is 2 , where we divided

by 2 since switching the order of v3 and v4 results in the same subgraph.

25. How many subgraphs of Kn are isomorphic to Ka,b ?


Solution : First suppose that a 6= b. Now to choose a Ka,b subgraph we divide the vertex set into a set
A of size a, a set B of size b, and the remaining n − a − b vertices. Adding all edges between A and B
gives us a Ka,b subgraph and this correspondence proves that the number of these subgraphs will be
n
a,b,n−a−b .
If a = b then we wish to choose a Ka,a . We can divide the vertex set into a set A of size a, a set A0 of size
a, and the remaining n − 2a vertices. Now adding all edges between A and A0 gives the desired Ka,a
subgraph. However the same subgraph will also be selected by interchanging A and A0 . Therefore in
1 n

this case the total number of Ka,a subgraphs is 2 a,a,n−2a .
Alternate Solution: For a 6= b first choose a set of size a for one vertex set in the bipartition, then
choose a set of size b from the remaining n − a vertices for the other vertex set in the bipartition. The
number of ways to do this is na n−a
 
b .
If a = b then we make the same
 choices, however we must realize that we are again double counting.
Therefore there are 12 na n−a
a subgraphs.

26. Up to isomorphism, find all graphs meeting each description.

(a) 5 vertices and 3 edges


(b) 5 vertices and 6 edges containing a cycle of length 4.
(c) 6 vertices and 8 edges containing a cycle of length 6.

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:

• {x1 , x2 }, {x2 , x3 }, . . . , {xn−1 , xn }, {xn , x1 },


• {y1 , y2 }, {y2 , y3 }, . . . , {yn−1 , yn }, {yn , y1 }, and
• {x1 , y1 }, {x2 , y2 }, . . . , {xn , yn }

(a) Draw the graph P3


(b) How many edges are in Pn ?
(c) How many paths of length 2 are in the graph Pn ?
(d) For n ≥ 5 how many cycles of length 4 are in the graph Pn ?

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:

• {x1 , x2 }, {x2 , x3 }, . . . , {xn−1 , xn }, {xn , x1 }, and


• {xi , y} and {xi , y 0 } for every 1 ≤ i ≤ n

(a) Draw the graph R4 .


(b) How many edges are in Rn ?
(c) How many subgraphs of Rn are isomorphic to K4− ?
(d) How many paths of length 3 are there in Rn ?

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).

n + 4n + 4n(n − 2) + 2n + 2n(n − 1) = −3n + 6n2

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.

Therefore, in total the number of paths of length 3 is

7n + 2(2n(n − 2) + n(n − 1)) = 7n + 6n2 − 10n = 6n2 − 3n.

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:

• {(i, j), (i, j + 1)} for 1 ≤ i ≤ a and 1 ≤ j < b.


• {(i, j), (i + 1, j)} for 1 ≤ i < a and 1 ≤ j ≤ b.

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

The smallest value of n for which this inequality is true is n = 5.

Alternate Solution: (Using Random Variables)


Let X be the number of heads. Recall that if we toss a coin n times, the probability of getting k heads
n

k
Pr(X = k) = .
2n
If we toss the coin 4 times then
4 4 4
  
2 + 3 + 4 6+4+1 11
Pr(X ≥ 2) = = = = 0.6875
24 16 16

12
MACM 201 Midterm 1 Practice Problems - Solutions

which is not high enough. If we toss the coin 5 times then


5 5 5 5
   
+ + + 10 + 10 + 5 + 1 26
Pr(X ≥ 2) = 2 3 4 5
= = = 0.8125
25 32 32
which is greater than 0.8. So 5 times.

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,

P r(B|A)P r(A) (7/9)(1/2) 7/18


P r(A|B) = = = = 49/76
P r(B) 38/63 38/63

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.

(a) What is the probability Alice selected a red ball?


(b) If Alice’s ball is red, what is the probability Bob had selected a red ball?

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:

P r(B) = 7/9, P r(B) = 2/9.

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

(b) We wish to determine P r(B|A). By Bayes’ theorem

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

39. In class we considered the following application of Baye’s theorem:


Suppose 10% of Olympic cyclists use steroid Z and the IOC develops a test for Z with the following
properties.

(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.

Is the candy we select more likely to be red of green?

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

(a) What is P r(X = k)?


(b) What is E(X)?
(c) How many times should we expect to roll the dice until the first 6 appears?

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

P r(X ≥ 5) = P r(X = 8) + P r(X = 9) + P r(X = 10)


   8  2    9  1    10  0
10 1 3 10 1 3 10 1 3
= + +
8 4 4 9 4 4 10 4 4
    
1 10 2 10
= 10 3 + 3+1
4 8 9
436
= 10 ≈ 0.00042 = 0.42%
4

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

times to get all 4 numbers.

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,

E(X) = 2 · P r(X = 2) + 3 · P r(X = 3) + 4 · P r(X = 4) + 5 · P r(X = 5)


2 6 12 20
= + + +
10 10 10 10
40
=
10
= 4.

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy