0% found this document useful (0 votes)
22 views5 pages

Mid2a Solution

This document appears to be a midterm exam for a computer science course. It contains 6 problems testing concepts like sets, functions, summations, and conversions between decimal and fractional representations of numbers.
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)
22 views5 pages

Mid2a Solution

This document appears to be a midterm exam for a computer science course. It contains 6 problems testing concepts like sets, functions, summations, and conversions between decimal and fractional representations of numbers.
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/ 5

Midterm II – Version A

CSE 191
Solution
Nov 7, 2014
12:00 - 12:50pm

First Name (Print): Last Name (Print):

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.

2. Support your answer.

3. Write your name on the top right-hand corner of every page.

4. There are 6 problems and 25 points in this exam.

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}

(b) Let A, B, C be three sets. Suppose A ∩ C = B ∩ C. Can you conclude A = B? If your


answer is “yes”, prove it. If your answer is “no”, give a counter example.

No. E.g. A = {1, 2}, B = {1, 3}, C = {1}

2 (3 points). Let A be the set of binary strings that satisfy the following conditions:

• The length of the binary string is 8.

• Either the first bit is 0; or the last two bits are 11.

Determine |A|. (Namely, determine the number of elements in A.)

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:

(a) the bride is next to the groom?

Choose 2 neighboring positions for bride and groom, 5 ways.


Arrange bride and groom in these 2 positions, 2 ways (bride either on the left or the right side of
the groom).
Arrange other 4 people,P (4, 4) ways.
So, there are 5 × 2 × P (4, 4) = 240 ways.

(b) the bride is NOT next to the groom?

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.

(c) the bride is positioned somewhere to the left of the groom?


(Hint: a row satisfies this requirement if and only if the reverse of the row does NOT satisfy
this requirement).

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.

Solution 2: Choose 2 positions for bride and groom, C(6, 2) ways.


Arrange bride and groom in these 2 positions, 1 way (bride on the left side of the groom).
Arrange other 4 people,P (4, 4) ways.
So, there are C(6, 2) × 1 × P (4, 4) = 360 ways.

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.

Fill the following table by “yes” or “no”:

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

Fill the following table by “yes” or “no”:

function? 1-to-1? onto?


f no – –
g yes yes yes
h yes no yes

3
Name
5 (2 points) Determine the cardinality of the following sets. (Namely: is it finite? countable
infinite? uncountable?)

• Z + × Z + = {(a, b) | a and b are positive integers }

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

• The number of atoms in the solar system.

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

(c) Convert the periodic decimal x =0.32405405405· · · = to a fraction.


Solution 1 (using the method discussed in class: =0.324̇05̇= 32405−32
99900 .
Solution 2: 0.324̇05̇ = 0.32 + 0.00405 ∞ i = 32 + 405 · 1 32373 1199
P
i=0 (1/1000) 100 100000 1−1/1000 = 99900 = 3700

You might also like