0% found this document useful (0 votes)
16 views

CS201A: Math For CS I/Discrete Mathematics Endsem Exam: Max Marks:150 Time:180 Mins. 23-Nov-2017

Uploaded by

RAHUL
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)
16 views

CS201A: Math For CS I/Discrete Mathematics Endsem Exam: Max Marks:150 Time:180 Mins. 23-Nov-2017

Uploaded by

RAHUL
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/ 13

CS201A: Math for CS I/Discrete Mathematics

Endsem exam

Max marks:150
Time:180 mins. 23-Nov-2017

1. Answer all 8 questions. It has 4 pages + 1 page for the standard normal distribution table.

2. Please start each answer to a question on a fresh page. And keep answers of
parts of a question together.

3. Just writing a number/final value/figure will not get you full credit. You must give justifi-
cations/ derivations in each case.

4. You can consult only your own handwritten notes. Nothing else is allowed. Keep any
electronic gadgets in your bag and the bag on or near the stage.

5. Where needed use the standard normal distribution table at the end of the question paper.

1. (a) You are the instructor of CS201 some time in the future and one of the questions in the
exam is:
Prove that:
Every integer n > 1 is a product of a unique non-decreasing sequence of prime numbers..
For example, 18 = 2 × 3 × 3, 20 = 2 × 2 × 5, 23 = 23 etc.
A student produces the following inductive proof:
Base case: n = 2. 2 is a prime and the unique sequence is trivially 2.
Strong inductive hypothesis: Assume that for integers ≤ n the claim holds.
Inductive step for n + 1: If n + 1 is a prime then the claim holds trivially since the non-
decreasing sequence contains only n + 1. On the other hand if n + 1 is composite then
there exist integers y, z < n such that n + 1 = y × z. Since y, z < n the claim holds
for y and for z. We can merge the non-decreasing sequences for y and z into a single
non-decreasing sequence whose product is n + 1.
Hence proved.
i. When the answer scripts are returned the student finds s/he has got a zero and s/he
approaches you with a regrading request. How will you defend your decision? In
other words what is wrong with the proof?

Solution:
The key problem with the proof is that in general for n + 1 the integers y, z are
not unique. For example, n = 18 = 3 × 6 = 2 × 9. So, it is necessary to show
that for all possible such distinct factorizations the final merged non-decreasing
sequence of primes is the same. Induction cannot help with this part of the proof
which is the key part.

ii. Is there a simple way to repair the student’s proof?

Solution:
No, there isn’t.
The claim is just the unique prime factorization theorem. The non-decreasing
part is irrelevant. The central point of a proof of the claim is to prove uniqueness
by showing that two different factorizations lead to the same prime factorization.
The induction does not help with that. The original proof was by Euclid.

(b) i. Let S be an infinite set and A = {a1 , . . . , an } be a finite set. Argue that there exists
a bijection from S ∪ A to S.

Solution:
Since S is an infinite set we can find a countably infinite subset that is an infinite
sequence of distinct elements s1 , s2 , . . . ∈ S and define the following mapping
from S ∪ A to S:
a1 7→ s1 , . . . , an 7→ sn .
s1 7→ sn+1 , s2 7→ sn+2 , . . ..
For s ∈ S − {a1 , . . . , an , s1 , s2 , . . .}, s 7→ s ∈ S
The above is clearly a bijection.
This is just a variant of Hilbert’s argument of how to accommodate n new guests
for a hotel with infinitely many rooms that has no vacancy.

ii. Find a bijection from the semi-closed interval (0, 1] ⊂ R to the interval [0, ∞) ⊂ R.

Solution:
The following function gives a bijection from (0, 1] to [0, ∞):
(
0, x = 1
f (x) = 1
x
0<x<∞

The above is clearly a bijection.

(c) Argue that a graph is a tree iff there is a unique path between every pair of nodes in the
graph.

Solution:
Let G be a tree and let there be two vertices x and y that have two non-identical
paths, say p1 and p2 between them. Now either p1 , p2 do not have any vertices in

Page 2
common except x and y or they do. In either case this implies that G has a cycle and
therefore cannot be a tree. So, paths p1 and p2 must be identical.
For the converse let there be a unique path between every pair of vertices in G. This
implies that for any pair of nodes x and y it is possible to reach from x to y (or the
reverse) but to get back to either x or y one has to retrace the previous path between
x and y so there can be no cycle in G. So, G is a connected, acyclic graph or a tree.

[(3,3),(5,3),6=20]
2. Assume all graphs in this question are connected.
Define the dual of a planar graph G = (V, E) as the graph G? = (V ? , E ? ) where every vertex
v ? ∈ V ? corresponds to a distinct face in G. So, |V ? | = |F | (no. of faces in G). We connect
vertices v1? , v2? ∈ G? by an edge e? ∈ E ? whenever an edge e ∈ E is a separating or boundary
edge for faces F1 , F2 in G corresponding to vertices v1? , v2? respectively. Note that v1? , v2? may
coincide for example when G has only one face so F1 , F2 are same.
(a) Through an example show that a simple graph G can have a dual G? that is not simple
- that is it can have multi-edges and self loops.

Solution:
The simplest example of this is a tree - a graph with just one face. Consider, the
graph (tree) below which has only one face:

G is a tree the corresponding dual G? has a single node and both self-loops and
multi-edges. The edge label in G? shows the corresponding edge in G.

(b) Again through an example show that two different planar embeddings of a planar graph
can have non-isomorphic duals.

Solution:
Consider two different planar embeddings of the same planar graph in the figure
below.

Page 3
The planar graph has 3 faces. But the embedding on the right has a node of degree 4
in the dual corresponding to the outside face. In contrast the graph on the left does
not have any node in the dual with degree 4. So the two duals corresponding to the
two planar embeddings cannot be isomorphic.

(c) Define the length of a face F1 of G to be the total length of the closed walk in G that
circumscribe
P or bound face F1 . If F is the set of faces in G argue that:
2|E| = Fi ∈F length(Fi ).

Solution:
Each edge in G leads to a corresponding edge in G? corresponding to the two faces
separated (can be same face) by the edge in G. So, |E| = |E ? |. In G? each face
corresponds to a node and its degree corresponds to the number of boundary edges
of the face. So, the sum in the formula is just the degree sum in G? which is twice
the number of edges in G? or 2|E ? | = 2|E|.

(d) Assume G is a bi-partite planar graph. What kind of graph is G? ? Justify your answer.

Solution:
A bi-partite graph G can only have cycles of even length. So, every face in G is
bounded by an even number of edges. This means that each node in the dual G? has
even degree. So, G? is an Eulerian graph. This is true even when G does not have
any cycles and therefore has only one face. In this case each edge in G will lead to a
self edge in G? . So, the only node in G? will have even degree.

[4,6,5,5=20]

3. (a) Let set S = {a, b, c, d, e, f }. Find the number of ways in which we can get two not
necessarily distinct pair of sets A, B ⊆ S such that A ∪ B = S. The order is not
important - so {a, c}, {b, c, d, e, f } is the same as {b, c, d, e, f }, {a, c}.

Solution:
A ∪ B = S in each case so for each element s ∈ S exactly one of the following must
hold i) s ∈ A, s 6∈ B, ii) s 6∈ A, s ∈ B, iii) s ∈ A, s ∈ B. This means there are
3|S| ways to choose A, B. However, every pair is being counted twice except when
|S| 6
A = B = S. So, the total pairs disregarding order is: 3 2−1 + 1 = 3 2−1 + 1 = 365.

(b) Let n > 1 be an odd integer. Argue that the sequence n C1 , n C2 , . . . , n C n−1 has an odd
2
number of odd numbers.

Solution:

Page 4
1 n
2
+ n C2 + . . . + n Cn−1 ] = 12 (2n − 2) = 2n−1 − 1. This is an odd number. So, the
[ C1
sequence must contain an odd number of odd numbers.

(c) Consider the 3×3 numbered grid below. Each square in the grid will be painted either
BLACK or WHITE. The colour for each square is decided by tossing a fair coin. Find
the probability that the grid does not have a 2×2 BLACK square (that is all 4 squares
are painted BLACK).
1 2 3
4 5 6
7 8 9
(Hint: Principle of inclusion-exclusion.)

Solution:
Let Bi , i = 1, 2, 4, 5 be the event that the 2×2 grid with i as the upper left corner
is painted BLACK, let P (Bi ) be the probability of that event. The probability that
there is at least one 2×2 BLACK square is by principle of inclusion-exclusion:
P (B1 ) + P (B2 ) + P (B4 ) + P (B5 ) − [P (B1 ∩ B2 ) + P (B1 ∩ B4 ) + P (B1 ∩ B5 ) + P (B2 ∩
B4 ) + P (B2 ∩ B5 ) + P (B4 ∩ B5 )] + [P (B1 ∩ B2 ∩ B4 ) + P (B1 ∩ B2 ∩ B5 ) + P (B1 ∩ B4 ∩
B5 ) + P (B2 ∩ B4 ∩ B5 )] − P (B1 ∩ B2 ∩ B4 ∩ B5 )
= 4 × ( 21 )4 − (4 × ( 21 )6 + 2 × ( 21 )7 ) + 4 × ( 21 )8 − ( 12 )9
95
= 512
95 417
So, probability that the grid does not have even one 2×2 black square is:: 1− 512 = 512

[7,5,8=20]
4. (a) For each recurrence below apply the Master theorem, if applicable, and determine a
solution bound for the recurrence. If not applicable say why it cannot be applied.
i. T (n) = 2n T ( n2 ) + n.

Solution:
For the Master theorem the recurrence must have the form:
n
T (n) = aT ( ) + f (n)
b
where constants a ≥ 1, b ≥ 1 and f (n) is the time taken at the top level of the
recurrence and often has the form nc . The Master theorem cannot be applied in
this case since a is not a constant.

ii. T (n) = 16T ( n4 ) + n!.

Solution:
Case 3 applies here. That is a < bc for n > 3 since ( n3 )n < n! (using Stirling’s
formula). So, T (n) = Θ(n!)

Page 5
(b) The recurrence equation T (n) = 2T ( n2 ) + n log n does not fit the Master theorem we
discussed in class (T (n) = aT ( nb ) + f (n)) where f (n) was nc . Use iterative unfolding to
get the Θ(.) solution for the given recurrence equation.

Solution:
Using iterative unfolding:
n
T (n) = 2T ( ) + n log n
2
n n
= 4T ( ) + n log n + n log )
4 2
n n
= 4T ( ) + n(log n + log )
4 2
n n n
= 8T ( ) + n(log n + log + log )
8 2 4
= ...
k−1
n X n
= 2k T ( ) + n( log i ) Use k = log n
k i=0
2
(log n − 1) × log n
= Θ(n) + n(log2 n − log n − log 2 × )
2
= Θ(n) + Θ(n log2 n)
= Θ(n log2 n)

(c) Consider integer n > 0 and define an ordered partition of n as a breakup of n into one or
more positive integers that add up to n but where order is important. That is for n = 4,
2 + 1 + 1, 1 + 2 + 1, 1 + 1 + 2 are different partitions. Derive the expression for the number
of ordered partitions for n without using generating functions.

Solution:
Consider the unary representation of n as a sequence of n 1s. A partition corresponds
to different ways of clustering the 1s by putting separators in the gaps between the
1s. We need to do this for 0 to n − 1 separators. When we have 0 separators we have
a single cluster of size or value n. When we have n − 1 clusters we have n clusters
each of size or value 1. In both cases there is only one possible way to do this. When
there is one separator we get n−1 C1 ways to get two clusters and similarly when we
have 2, 3, . . . , n − 2 separators. So, for
Pkn−1separators we have n−1 Ck ordered partitions.
n−1
The total number of partitions is: i=0 Ci = 2n−1 . So, there are 2n−1 ordered
partitions for n.

[(3,3),9,5=20]
5. (a) Let F be a σ-Field and let A, B ∈ F. Are A\B (A difference B) and A4B (symmetric
difference between A and B) in F? Justify.

Page 6
Solution:
Since F is a sigma field it is closed under complementation and countable union.
A\B = A ∩ B c = (Ac ∪ B)c so A\B ∈ F.
A4B = (A\B) ∪ (B\A) so from the previous result A4B ∈ F.

(b) Let E1 , . . . , En be events. You are given that at least one of Ei , 1 ≤ i ≤ n is certain
to occur and definitely no more than two of the events can occur. Let P (Ei ) = p and
P (Ei ∩ Ej ) = q, i 6= j. Argue that the lower bound on p is n1 and the upper bound on q
is n2 .

Solution:
certain P ( Pni=1 Ei ) = 1.
S
Since at least one event isS P Also, since definitely no more than
n n
two events can occur: P ( i=1 Ei ) = i=1 Ei − i6=j P (Ei ) ∩ P (Ej ) = 1.
So, we get np − n(n−1)
2
q = 1 or np = 1 + n(n−1)
2
q. Since smallest value of q is 0,
1
np ≥ 1 =⇒ p ≥ n .
n(n−1)
Since p is at most 1 we have 2
q ≤ n − 1 =⇒ q ≤ n2 .

[(2,2),(3,3)=10]

6. You have 5 coins. Two of them have Head on both sides, one has Tail on both sides and two
are normal (that is Head on one side and Tail on the other). Answer the following (carefully
specify each event for clarity since there are a sequence of conditional probabilities):
(a) You close your eyes pick a coin and toss it. What is the probability the bottom face is a
Head?

Solution:
Since there are multiple tosses we will use superscripts to indicate the toss number.
1
Let BH be the event the bottom is a Head after first toss, TH1 the event the top is
a Head after first toss, HH the event that a coin with two heads was chosen, T T
the event the coin with two Tails was chosen and HT the event the normal coin was
chosen.
1 2 2 1 1
P (BH ) = ( × 1) + ( × ) + ( × 0)
5 5 2 5
2 1
= +
5 5
3
=
5

(b) You open your eyes and see that the top face is a Head. What is the probability the
bottom face is Head?

Page 7
Solution:
1
We must calculate P (BH |TH1 ).
P (BH1 ,T 1 )
P (HH) 2/5
1
P (BH |TH1 ) = P (TH1)
H
= 1)
P (TH
= 3/5
= 23 . The probability for TH1 is the same as in
a - that is 53 .
Another way is to see that the probability that both top and bottom are Heads is
the same as the probability of event HH which is 25 . This must be divided by the
probability that the Top is a Head, (TH1 , which is 52 ×1+ 25 × 12 = 35 ). So, the probability
is 23 .

(c) You shut your eyes and again toss the same coin. What is the probability that the bottom
face is a Head?

Solution:
2
We need P (BH |TH1 ).
2
2 P (BH , TH1 )
P (BH |TH1 ) =
P (TH1 )
( 25 × 1) + ( 52 × 12 × 12 )
= 3
5
( 12 )
=
( 35 )
5
=
6

(d) You open your eyes and see that the top face is a Head. What is the probability that the
bottom face is a Head?

Solution:

Page 8
2
We need P (BH |TH2 ).
2
2 P (BH , TH1 , TH2 )
P (BH |TH1 , TH2 ) =
P (TH2 )
2 2 1 1
P (TH2 ) = ( × 1) + ( × × )
5 5 2 2
2 1
= +
5 10
1
=
2
2 2
P (BH , TH1 , TH2 ) = only possible if coin is one with both heads
5
2 1 2 ( 25 )
P (BH |TH , TH ) = 1
(2)
4
=
5

(e) You discard the above coin, pick a random coin from the remaining and toss it. What is
the probability the top face is a Head?

Solution:
From d above the probability the coin with two Heads was discarded is 54 so the prob-
ability that a normal was discarded is 15 . So, the four coins left are with probability
4
5
, {HH, N, N, T T } and with probability 51 , {HH, HH, N, T T }. So, the probability
the top is a Head when a random coin is chosen from the set of four coins is:
4 1 1 1 1 4 1 1 1
=1×( × + × )+ ×( × + × )
5 4 5 2 2 5 2 5 4
1 1 1 2 1
=( + )+ ×( + )
5 10 2 5 20
3 9
= +
10 40
21
=
40

[4×5=20]

7. (a) You have a fair die with 6 faces marked 1 to 6. You continue to roll the die repeatedly
and only stop when either you roll a 1 or you voluntarily decide to stop at some point.
When you stop you get a score that is equal to the value of the last roll. So your last
score is either 1 or the value of the last roll before you decided to stop.
i. What stopping strategy will you choose to maximize your expected score.

Page 9
Solution:
The relevant value to consider for stopping is clearly the value of the current roll.
Let this be v. It is also clear that a value that is greater than v will also qualify
for stopping. Let S(v) be the expected score if we stop at value v or larger. We
calculate S(v) for different v.

S(6) = 6 × P (6 appears before 1) + 1 × P (1 appears before 6)


1 1
=6× +1×
2 2
= 3.5
6+5 2 1
S(5) = × +1×
2 3 3
=4
6+5+4 3 1
S(4) = × +1×
3 4 4
=4
6+5+4+3 4 1
S(3) = × +1×
4 5 5
19
=
5
The expected value is maximum at 4 and then falls off. So, the strategey to get
the maximum expected score is to stop if either 4, 5 or 6 is rolled.
Note that we are using the fact that the die is fair to calculate which value(s)
will appear earlier assuming all values are equi-probable.

ii. If the score was the square of the last rolled value what stopping strategy will max-
imize your expected score.

Solution:
One can do a similar calculation as earlier but now use the square of the value.
S(6) = 36 × P (6 appears before 1) + 1 × P (1 appears before 6)
1 1
= 36 × + 1 ×
2 2
= 18.5
36 + 25 2 1
S(5) = × +1×
2 3 3
= 20.67
36 + 25 + 16 3 1
S(4) = × +1×
3 4 4
= 19.5
Now the maximum expected value is obtained at 5 and it drops off after that.

Page 10
So the strategy in this case is to stop whenever 5 or higher is rolled.

(b) What exactly is the meaning of an α-significance value?

Solution:
Assuming H0 (null hypothesis) is true it is the probability of obtaining a value of the
test statistic (e.g. mean) as contradictory to H0 as the one obtained from the test
sample.

(c) The target thickness for some sheet metal for use in manufacturing some part is 245mm.
A sample of 50 sheets is obtained and the thickness of each one is determined, resulting
in a sample mean thickness of 246.18 mm and a sample standard deviation of 3.60mm.
Does this data suggest that the true average sheet thickness is something other than the
target value at α = 0.02? (Use the table for the standard normal distribution at the end
of the question paper where necessary.)

Solution:
H0 : µ = 245, Ha : µ 6= 245.
√ = 246.18−245
Test statistic z = x̄−245
s/ n

3.6/ 50
= 2.32
Since two sided 0.02-value=2(1 − Φ(2.32)) = 0.0204.
.0204 > .02 so H0 cannot be rejected.

[(5,5),5,5=20]
8. (a) If events E1 , . . . , En are independent events then show that
n
Y
P (E1 ∪ E2 ∪ . . . ∪ En ) = 1 − (1 − P (Ei ))
i=1

Solution:
n
[ n
\
P( Ei ) = P (( Eic )c ) DeMorgan
i=1 i=1
n
\
= 1 − P( Eic ) probability of complement
i=1
Yn
=1− Eic Independence of Eic
i=1
Yn
=1− (1 − P (Ei )) probability of complement
i=1

Page 11
i
(b) Let X be a Poisson random variable. Then P (X = i) = e−λ λi! , i = 0, 1, 2, . . . where
parameter λ > 0. Derive the mean, and variance of X.

Solution:
To compute the mean we calculate E[X].

X λi
E[X] = ie−λ
i=0
i!

−λ
X λi−1
= λe
i=1
(i − 1)!

−λ
X λj
= λe j=i-1
j=0
j!
−λ λ
= λe e

To compute the variance we use E[(X − µ)2 ] = E[X 2 ] − µ2 .



X λi
2
E[X ] = i2 e−λ
i=0
i!

X λi−1
=λ ie−λ
i=1
(i − 1)!

X λj
=λ (j + 1)e−λ j=i-1
j=0
j!
∞ j ∞
X
−λ λ
X λj
= λ( je + e−λ ) First term is the mean, second is 1
j=0
j! j=0
j!
= λ(λ + 1)
E[(X − µ) = E[X 2 ] − µ2
2

= λ2 + λ − λ2

(c) Assume that the height in inches of all college basketball players in India is a normally
distributed random variable with µ = 71 and σ 2 = 6.25.
i. What percentage of college basketball players are over 74 inches tall?

Solution:
We first calculate z = X−µ
σ
= 74−71
2.5
= 1.2. The normal table shows that Φ(1.2) =
0.8849. So, the fraction taller than 74 inches is 1.0 − 0.8849 = 0.1151 or 11.51%.

Page 12
ii. What percentage of college basketball players in the six foot club are over 77 inches
tall?

Solution:
Fraction of players in the six foot club (that is ≥ 6ft will be: z = 72−71
2.5
= 0.4.
77−71
So, 1 − Φ(0.4) = 0.3446. Fraction of players over 77 inches are z = 2.5 = 2.4.
So, 1 − Φ(2.4) = 0.0082. So, the fraction in six foot club over 77 inches is:
0.0082
0.3446
= 0.0238. Approximately, 2.4%.

[5,(5,5),(2,3)=20]

Page 13

You might also like