You are on page 1of 9

THE UNIVERSITY OF THE WEST INDIES

Semester l Semester II Supplemental/Summer School


Mid-Semester Examinations of: October /March /June 2012
Originating Campus: Cave Hill Mona St. Augustine
Mode: On Campus By Distance

Course Code and Title: COMP2101/CS20S Discrete Mathematics for Computer Scientists


Date: Friday, October 19, 2012 Time: 2:00 p.m.

Duration: 1 Hour. Paper No: 1 (of 1)

Materials required:
Answer booklet: Normal Special Not required
Calculator: Programmable Non Programmable Not required
(where applicable)
Multiple Choice answer sheets: numerical alphabetical 1-20 1-100

Auxiliary/Other material(s) Please specify: None


Candidates are permitted to bring the following items to their desks:


Instructions to Candidates: This paper has 2 pages & 6 questions.

Candidates are reminded that the examiners shall take into account the proper use of the English Language
in determining the mark for each response.


This Examination consists of Two Sections.

All questions are COMPULSORY.

Calculators are allowed.




2


1. Assuming that the functions f, g and h take on only positive values,
Prove or disprove the following:
)) ( ( ) ( ) ( ) ( then )), ( ( ) ( )) ( ( ) ( n h n h n g n f n h n g and n h n f O = + + O = O = [3]

2. (a) Consider the random experiment of tossing nine fair coins. What is the
probability that the number of heads and the number of tails differ by at
most 3? [3]
(b) By using the inclusion-exclusion principle
Calculate the number of bit strings of length 8 that begin with two 0s,
have seven consecutive 0s, or end with a 1 bit [4]


3. The seven Double dominoes of a certain pack are placed in a bag. The Double-Blank
is three times as likely to be pulled as the dominoes Double-Ace, Double-Four and
Double-Six. The Double-Six is two times as likely to be pulled as Double-Three and
Double-Five. Double-Five is two times as likely to be pulled as Double-Deuce.
i. Assign probabilities to the seven outcomes in the sample space [5]
ii. Suppose that the random variable X, is assigned the value of the number
that appears when the domino is pulled. Therefore Double-Blank is
assigned 0, Double-Ace is assigned 2, Double-Deuce is assigned 4,
Double-Three is assigned 6, and so on. If the expected value is denoted by
E(X) =

=
n
i
i i
x X x p
0
) ( ) (
where p(x
i
) is the probability for the event x
i
,
what is the expected value of X? [2]


4. (a) In a given town only 2 percent of all robberies will be reported to the
police. Find the probability that among 300 robberies in that town,
at least three will be reported to the police. [3]

(b) It is said that if you study intensely the probability of passing this COMP2101
Mid-term examination is 85%, if you studied lightly the probability of passing
the examination is 40%, and if you studied none at all the probability of
passing is 5%. Suppose, we know that 60% of the students study intensely,
35% of them study lightly and 5% do not study, what is the probability of
passing this COMP2101 Mid-term examination? [4]


5. Consider the recurrence function
T(n) = 8T(n/2) + n
3

Give an expression for the runtime T(n) if the recurrence can be solved with the
Master Theorem. Assume that T(n) = 1 for n 1. [4]


6. If there are 71 students who have completed a Computer Science course and 12
possible grades that could have been attained, use the Pigeonhole Principle to show
that there is a grade that at least six students attained. [2]

~~~~~~~~ END OF PAPER ~~~~~~~~
3

1. Assuming that the functions f, g and h take on only positive values,
Prove or disprove the following:
)) ( ( ) ( ) ( ) ( then )), ( ( ) ( )) ( ( ) ( n h n h n g n f n h n g and n h n f O = + + O = O = [3]

Solution 1
[Stating f(n) = O(h(n)) and g(n) = O (h(n)) in terms of the inequality - 1 mark]
[Using assumption h(n) = O(h(n)) and stating in terms of the inequality - mark]
[Using | f(n) | + | g(n) | + | h(n) | = | f(n) + g(n) + h(n) | for positive - mark]
[Other logical steps of the Proof - 1 mark]

Proof that )) ( ( ) ( ) ( ) ( then )), ( ( ) ( )) ( ( ) ( n h n h n g n f n h n g and n h n f O = + + O = O =

Given f(n) = (h(n)) and g(n) = (h(n))

f(n) = (h(n))
C
1
| h(n) | | f(n) | C
2
| h(n) |
where C
1
and C
2
are constants
g(n) = (h(n))
C
3
| h(n) | | g(n) | C
4
| h(n) |
where C
3
and C
4
are constants
We accept that
h(n) = (h(n))
As C
5
| h(n) | | h(n) | C
6
| h(n) |
where C
5
and C
6
are constants

By Addition
(C
1
+ C
3
+ C
5
) | h(n) | | f(n) | + | g(n) | + | h(n) | (C
2
+ C
4
+ C
6
) | h(n) |
C
7
| h(n) | | f(n) | + | g(n) | + | h(n) | C
8
| h(n) |
where C
7
and C
8
are new constants
Given the assumption that f(n), g(n) and h(n) are positive
C
7
| h(n) | | f(n) + g(n) + h(n) | C
8
| h(n) |

f(n) + g(n) + h(n) = (h(n))


2. (a) Consider the random experiment of tossing nine fair coins. What is the
probability that the number of heads and the number of tails differ by at
most 3? [3]
(b) By using the inclusion-exclusion principle
Calculate the number of bit strings of length 8 that begin with two 0s,
have seven consecutive 0s, or end with a 1 bit [4]

Solution 2
[(a) Correct formula - 1 marks]
[ Other logical steps towards solution - 1 mark ]
[ Final Answer - mark ]
[(b) Correct formula for inclusion-exclusion principle for A
1
, A
2
, A
3
- 1 mark ]
[ Other logical steps towards solution - 2 marks ]
4
[ Final Answer - mark ]

(a) The possible combinations for the exact number of heads and tails such that they differ
by at most 3 are

6 heads and 3 tails
5 heads and 4 tails
4 heads and 5 tails
3 heads and 6 tails

These four cases are mutually exclusive and as such, the probability that the number
of heads and the number of tails differ by at most 3 is given by;

8203 . 0
512
420
512
84 126 126 84
512
3
9
4
9
5
9
6
9
= =
+ + +
=
+ + + C C C C


(b) Inclusion-Exclusion Principle
( )
3 2 1 3 2 3 1 2 1 3 2 1 3 2 1
A A A A A A A A A A A A A A A + + + + + =

Let A
1
= set of all bit strings of length 8 that begin with two 0s
Let A
2
= set of all bit strings of length 8 that have seven consecutive 0s
Let A
3
= set of all bit strings of length 8 that end with a 1 bit

Now
|A
1
| = 2
6
= 64
|A
2
| = 1+1+1 = 3
|A
3
| = 2
7
= 128

|A
1
A
2
| = 2
|A
2
A
3
| = 1
|A
1
A
3
| = 2
5
= 32

|A
1
A
2
A
3
| = 1

Therefore, the number of bit strings of length 8 that begin with two 0s, have seven
consecutive 0s, or end with a 1 bit is given by

161 1 ) 32 1 2 ( 128 3 64
3 2 1
= + + + + + = A A A


3. The seven Double dominoes of a certain pack are placed in a bag. The Double-Blank
is three times as likely to be pulled as the dominoes Double-Ace, Double-Four and
Double-Six. The Double-Six is two times as likely to be pulled as Double-Three and
Double-Five. Double-Five is two times as likely to be pulled as Double-Deuce.
i. Assign probabilities to the seven outcomes in the sample space [5]
ii. Suppose that the random variable X, is assigned the value of the number
that appears when the domino is pulled. Therefore Double-Blank is
assigned 0, Double-Ace is assigned 2, Double-Deuce is assigned 4,
Double-Three is assigned 6, and so on. If the expected value is denoted by
5
E(X) =

=
n
i
i i
x X x p
0
) ( ) (
where p(x
i
) is the probability for the event x
i
,
what is the expected value of X? [2]

Solution 3
[i. Probability Function ]
[ Correct initial layout of solution - 2 mark ]
[ Logical steps towards correct solution - 3 marks ]
[ii. Expected Value ]
[ Correct solution - 2 marks ]
[ mark is awarded if answer is incorrect ]
[ and any part of the solution is correct ]

i. P(0) = 3 x P(1) = 3 x P(4) = 3 x P(6)
P(6) = 2 x P(3) = 2 x P(5)
P(5) = 2 x P(2)

) (x P
= 1
P(0) + P(1) + P(2) + P(3) + P(4) + P(5) + P(6) = 1

Interpreting in terms of P(0)
P(0) = P(0)
P(1) = 1/3 x P(0)
P(2) = x P(5) = x x P(6) = x x 1/3 x P(0) = 1/12 x P(0)
P(3) = x P(6) = x 1/3 x P(0) = 1/6 x P(0)
P(4) = 1/3 x P(0)
P(5) = x P(6) = x 1/3 x P(0) = 1/6 x P(0)
P(6) = 1/3 x P(0)

P(0) + 1/3*P(0) + 1/12*P(0) + 1/6*P(0) + 1/3*P(0) + 1/6*P(0) + 1/3*P(0) = 1

(12 + 4 + 1 + 2 + 4 + 2 + 4)/12*P(0) = 1
P(0) = 12/29

P(0) = 12/29
P(1) = 4/29
P(2) = 1/29
P(3) = 2/29
P(4) = 4/29
P(5) = 2/29
P(6) = 4/29
6
ii. N.B. Expected Value =
) (x xP

where x is the possible outcome and P(x) is the probability associated with each
outcome.

Expected Value
= 0P(0) + 2P(1) + 4P(2) + 6P(3) + 8P(4) + 10P(5) + 12P(6)

= 0 x 12/29 + 2 x 4/29 + 4 x 1/29 + 6 x 2/29 + 8 x 2/29 + 12 x 4/29

= 88/29 or 3 1/29

= 3.0345


4. (a) In a given town only 2 percent of all robberies will be reported to the
police. Find the probability that among 300 robberies in that town,
at least three will be reported to the police. [3]
(b) If you study intensely the probability of passing this COMP2101 Mid-term
examination is 85%, if you studied lightly the probability of passing the
examination is 40%, and if you studied none at all the probability of passing is
5%. The course lecturer is sure that 60% of the students study intensely,
35% of them study lightly and 5% do not study. Given that you pass this
Mid-term examination, what is the probability that you studied intensely? [4]

Solution 4
[(a) Identification of correct Distribution - mark ]
[ Correct Formula - mark ]
[ Correct steps and solution - 2 marks ]
[(b) Correct Layout of Problem - mark ]
[ Correct Formula - 1 mark ]
[ Correct steps and solution - 2 marks ]
[ Final Answer - mark ]

(a) Poisson

As = n = 300 x 0.02 = 6

p(> 3; 6) = 1 p(<3; 6)

= 1 ( p(0; 6) + p(1; 6) + p(2; 6) )

= 1 ( (6
0
*e
-6
)/0! + (6
1
*e
-6
)/1! + (6
2
*e
-6
)/2! )

= 1 (0.002479 + 0.014873 + 0.044618)

,... 2 , 1 , 0
!
) ; (
=
=

x
x
e
x p
x

7
= 1 0.061969

= 0.938031 or 0.9380

OR

Binomial

b(> 3; 300,0.02) = 1 b(<3; 300, 0.02)

= 1 (b(0;300,0.02) + b(1;300,0.02) + b(2;300,0.02))
= 1 (
300
C
0
x 0.02
0
x 0.98
300
+ +
300
C
2
x 0.02
2
x 0.98
298


= 1 (0.002333 + 0.014281 + 0.043571)
= 1 0.060184

= 0.939816 or 0.9398


(b) Let I - Study Intensely
L - Study Lightly
N - Study None at all

C - Passing the course COMP2101 Mid-term examination
Given
P(C|I) = 0.85
P(C|L) = 0.40
P(C|N) = 0.05

P(I) = 0.60
P(L) = 0.35
P(N) = 0.05

Required
P(I|C)

7812 . 0
6525 . 0
51 . 0
0025 . 0 14 . 0 51 . 0
51 . 0
) 05 . 0 )( 05 . 0 ( ) 35 . 0 )( 40 . 0 ( ) 60 . 0 )( 85 . 0 (
) 60 . 0 )( 85 . 0 (
) ( ) ( ) ( ) | ( ) ( ) (
) ( ) (
) | (
=
=
+ +
=
+ +
=
+ +
=
N P N C P L P L C P I P I C P
I P I C P
C I P

n 0,1,2.., for x ) - (1 C ) n, b(x;
x - n x n
x
= = u u u
8


5. Consider the recurrence function
T(n) = 8T(n/2) + n
3

Give an expression for the runtime T(n) if the recurrence can be solved with the
Master Theorem. Assume that T(n) = 1 for n 1. [4]

Solution 5
[ Finding the critical exponent - mark ]
[ Determining Order of Growth by comparison of f(n) and n
E
- 1 mark ]
[ Correct Master Theorem Case selection - mark ]
[ Stating clearly the Master Theorem Case selection - 1 mark ]
[ Correct solution stated using - 1 mark ]

Given
T(n) = 8f(n/2) + n
3


Consider the recurrence:
T(n) = aT(n/b) + f(n)
where a, b are constants and g(n) is an arbitrary function in n,

Let the critical exponent, E = log
b
a
The critical exponent, E
E = log
2
8 = 3

By examining the overhead function f(n) with n
E

f(n) = n
3
and n
E
= n
3

Therefore
f(n) = n
3
= (n
E
) = (n
3
)
We have
g(n) = (n
E
)

As f(n) = (n
E
)
Master Theorem Case 2 holds

We conclude that
the solution for the equation
T(n) = 8T(n/2) + n
3

is
T(n) = (f(n) log

n) or T(n) = (n
E
log

n) or T(n) = (n
logba
log

n)

T(n) = (n
3
log n)


6. If there are 71 students who have completed a Computer Science course and 12
possible grades that could have been attained, use the Pigeonhole Principle to show
that there is a grade that at least six students attained. [2]

Solution 6
[ Correct Formula - mark ]
[ Correct steps and solution - 2 marks ]

9
71 students have completed a Computer Science Course
12 possible grades

Let X the set of students who have completed a Computer Science Course
Y the set of possible grades

n the number of students who have completed a Computer Science Course
k the number of possible grades

Such that
|X| = n
|Y| = k

The number of students are to be distributed among the number of grades

Using the Pigeonhole principle
If n objects are distributed into k boxes, then at least one box must contain objects.
(
(
(

k
n

It follows that
There is a grade that at least
(
9167 . 5
12
71
=
(
(
(

students attained
Therefore,
There is a grade that at least 6 students attained.

You might also like