Mid2a Solution
Mid2a Solution
CSE 191
Solution
Nov 7, 2014
12:00 - 12:50pm
UB ID number:
1. This is a closed book, and closed neighbor exam. You may use a calculator, and a two-sided
sheet of notes.
5. Once the instructor announces “time’s up”, you must stop writing immediately.
It’s your responsibility to give your exam to TA within 2 mins.
0
Name
1 (2 + 2 = 4 points).
(a) Let A and B be two sets. Suppose that:
• A − B = {1, 5, 7, 8};
• B − A = {2, 10};
• A ∩ B = {3, 6, 9}.
What is A and B?
A = (A − B) ∪ (A ∩ B) = {1, 3, 5, 6, 7, 8, 9}
B = (B − A) ∪ (A ∩ B) = {2, 3, 6, 9, 10}
2 (3 points). Let A be the set of binary strings that satisfy the following conditions:
• Either the first bit is 0; or the last two bits are 11.
Let A1 be the set of 8-bit long binary strings whose first bit is 0. |A1 | = 27
Let A2 be the set of 8-bit long binary strings whose last two bits are 11. |A2 | = 26
Then A1 ∩ A2 is the set of 8-bit long binary strings whose first bit is 0 and last two bits are 11.
|A1 ∩ A2 | = 25
Then A1 ∪ A2 is the set of 8-bit long binary strings whose first bit is 0 or last two bits are 11.
|A| = |A1 ∪ A2 | = |A1 | + |A2 | − |A1 ∩ A2 | = 27 + 26 − 25 = 160
1
Name
Note: For problem 3, the solutions may involve factorial, combinations, permutations and
powers, such as 6!, C(6, 3), P (10, 5), or (−5)k . In such cases, your solutions must be given in terms
of these expressions. The numerical solution is not enough, and is not required. For example, if
the solution is P (7, 3) × 25 , you can just write it this way, or 7 × 6 × 5 × 25 . Its numerical value
6720 is neither enough, nor required.
3 (6 points). How many ways can a photographer at a wedding arrange 6 people (including the
bride and the groom) in a row, if:
The number of all the possible ways to arrange 6 people is P (6, 6).
Remove the ways that bride is next to the groom, which is 5 × 2 × P (4, 4) ways.
So, there are P (6, 6) − 5 × 2 × P (4, 4) = 480 ways.
Solution 1: There are P (6, 6) ways to arranged 6 people. Exactly half of these arrangements
satisfy the requirement. So the answer is P (6, 6)/2 = 360.
2
Name
4 (3 + 3 = 6 points). For this problem, you only need to give answer. Support is NOT required.
Let R be the set of real numbers; R+ be the set of positive real numbers; Z be the set of
integers; Z + be the set of positive integers.
(a) Consider the following functions:
• f : R → R : f (x) = 2x − 1.
• g : Z → Z : g(x) = 2x − 1.
• h : R+ → R : h(x) = x2 − 1.
1-to-1? onto?
f yes yes
g yes no
h yes no
(b) Let f , g and h be the functions represented by the following arrow diagrams.
f g h
3
Name
5 (2 points) Determine the cardinality of the following sets. (Namely: is it finite? countable
infinite? uncountable?)
Countable infinite
• (0, 0.02) = {x ∈ R | 0 < x < 0.02} = the set of real numbers between 0 and 0.02
Uncountable
• P (Z + ) = the power set of positive integers. (Namely the set of subsets of positive integers.)
Uncountable
Finite
6 (2+1+1 = 4 points).
(a) Find the value of the following sum:
6
X
(3i − 3 · 2i )
i=0
You must use the summation formula, (not by calculating the sum term by term.)
P6 i P6 P6 37 −1 27 −1
i=0 (3 − 3 · 2i ) = i
i=0 (3 ) −3 i
i=0 (2 ) = 3−1 −3· 2−1 = 712
P∞ i
(b) Find the value of the following sum: i=0 (2/3) = 1 + (2/3)1 + (2/3)2 + (2/3)3 + · · ·
P∞ i ( 32 )∞ −1 0−1
i=0 (2/3) = 2
−1
= 2
−1
=3
3 3