Professional Documents
Culture Documents
SCHOOL OF COMPUTING
EXAMINATION FOR
SEMESTER 2 AY 2008/2009
INSTRUCTIONS TO CANDIDATES
1. This examination paper contains FOUR questions and comprises SIX printed pages,
including this page.
Matriculation NO:
Total
PAGE 2 CS1231
Question A [60 marks]. For each of the following, just write down the answers in the
spaces provided. Detailed workings are not required. Also numerical answers are to be
¡ ¢¡ ¢
written as integers. For example, do not write 51 31 or 33 , but write 15 or 27 instead.
(a) Is 10 ∈ B
(b) Is −10 ∈ D?
(c) Is B = D?
Soln: (a) No (b) Yes −10 = 3(−3) − 1. (c) Yes. If n = 3j + 2, then n = 3(j + 1) − 1,
thus B ⊆ D. If n = 3j − 1, then n = 3(j − 1) + 2. Thus D ⊆ B. So B = D.
1
(3) Let f : R− → (0, 1) be the function defined by f (x) = x2 +1 .
Find its inverse function.
p p
Soln: Let y = 1/(x2 + 1). Then x = − (1 − y)/y. Thus f −1 (x) = − (1 − x)/x.
√ √
(4) Compute b− 2 − d− 2ec.
√
Soln: d− 2e = −1. Thus ans= −1.
(5) How many integers in [1, 99999] contain each of 2, 3, 4, 5 exactly once?
Soln: Consider each number as a 5-digit number, appending 0 when necessary. For
example 23 is written as 00023. There are five choices of positions for 2, four for 3, three for
4 and two for 5. The remaining digit can be filled in 6 ways. Thus ans= 5 × 4 × 3 × 2 × 6 =
720.
Soln: Now 101 = (1100101)2 . So 3101 = 364 332 34 31 . The computation then goes as
follows, with all congruence modulo 98:
3, 32 ≡ 9, 34 ≡ 81, 38 ≡ 812 ≡ 93, 316 ≡ 932 ≡ 25, 332 ≡ 252 ≡ 37, 364 ≡ 372 ≡ 95.
Finally
3101 ≡ 364 332 34 31 ≡ 95 · 37 · 81 · 3 ≡ 75 (mod 100).
PAGE 3 CS1231
Soln: 14039 Mod 1529 = 278, 1529 Mod 278 = 139, 278 Mod 139 = 0. Therefore
gcd(14039, 1529) = 139.
1529 Div 278 = 5 and 14039 Div 1529 = 9. Thus 1529 = 5 · 278 + 139 and 14039 =
9 · 1529 + 278. Hence
Is 877 a prime?
√
Soln: k = b 877c = 29.
Yes.
(9) How many bit strings of length 10 in which the ‘1’ bit occurs in pairs? (For example
0110000110 has the property while 0011100110 does not.)
Soln: Let n be the number of pairs of ‘1’. Then each such string is formed by inserting
the pairs into a string of 10 − 2n ‘0’. The ‘0’s create 10 − 2n + 1 spaces into which we may
¡ ¢
insert the n pairs and there are 11−2nn ways to do it. So the answer is
µ ¶ µ ¶ µ ¶ µ ¶
11 9 7 5
+ + + = 1 + 9 + 21 + 10 = 41.
0 1 2 3
(a) In G, abdc is a path of length 3 from a to c. Find 2 other paths of length 3 from a
to c.
a b c d ab ac ad bc bd cd dd
à ! à !
c c
d d
(11) In how many ways can 4 distinct integers be chosen from {1, . . . , 100} so that their
sum is even?
PAGE 5 CS1231
Soln: We have the following 3 cases: 4 even, 2 even 2 odd, 4 odd. Thus the answer is
µ ¶ µ ¶µ ¶ µ ¶
50 50 50 50
+ + = 1961225.
4 2 2 4
(13) Find a minimal spanning tree of the following graph. Compute its weight.
a........................3.......................b............................4........................c.........................2.......................d...
•.... •.... •.... •....
... .. ... ..
... ... ... ...
... .. ... ..
... .. ... 3 ..
... 4 .
.
.
2 ... ... 6
... .
. ... ..
...
... f 5
.
.
.
.
. 4 g ...
... 5
....................................................................................................................................................
.
..
..
e• .... • .... • ... .... •h
.. .. .... ..
... .. .. ..
.. ... ... ...
.. .. .. ..
.. 5 .. 3 ... 5 .. 4
... ... . ...
.. .. .... ..
.. .. .. ..
.. 4 . 4 . 2
...................................................................................................................................................
.
• • • •
i j k l
Its weight:
bf (2), ab(3), jf (3), ae(4), bc(4), cd(2), cg(3), jk(4), kl(2), lh(4), ij(4) Total weight: 35
6 | 7n − 1 ∀n ∈ Z∗ .
Inductive step: Assume that the result holds for some k ≥ 0, i.e., 6 | 7k − 1, or
7k − 1 = 6q for some q ∈ Z. Now consider the case k + 1.
Then 7k+1 − 1 = 7(7k ) − 1 = 7(6q + 1) − 1 = 6(7q + 1). Thus 6 | 7k+1 . The proof is
now complete by M.I.
PAGE 6 CS1231
Question C [15 marks]. (a) Prove that if A, B, C are subsets of a finite set S, then
(b) Find the number of integers in [1, 10000] which are multiples of 2 or multiples 3 or
not multiples of 5.
Soln: Let Ai be the set of multiples of i in [1, 10000]. Then |A5 | = 2000, |A10 | = 1000,
|A15 | = 666, A30 | = 333. Thus the answer is 10000 − 2000 + 1000 + 666 − 333 = 9333.
PAGE 7 CS1231
(a) 1, 2, 4, 7 (b) 3, 5, 8, 13
¡¢ ¡ ¢ ¡t¢
(d) Let k ∈ Z+ . Then ∃t ∈ Z+ such that 2t < k ≤ t+1 . Let m = k − 2 and
¡m+n−1¢ ¡t¢ ¡t¢ 2
n = t − m + 1. Then f (m, n) = 2 + m = 2 + k − 2 = k. It remains to show that
n = t − m + 1 > 0, or t − m ≥ 0.
¡¢ ¡¢ t(t+1) ¡t+1¢
Now t − m = t − k + 2t . But t + 2t = 2 = 2 ≥ k. Thus t − m ≥ 0 as required.
Now assume that P (k) is true, i.e., there exist m, n ∈ Z+ such that f (m, n) =
¡m+n−1¢
2 + m = k.
¡ ¢
If n ≥ 2, then f (m + 1, n − 1) = m+n−1
2 + m + 1 = k + 1.
¡ ¢ ¡m+1¢ ¡ ¢ ¡m¢
If n = 1, then f (m, 1) = m2 + m = k. Thus f (1, m + 1) = 2 +1 = m
2 + 1 +1 =
¡m¢
2 + m + 1 = k + 1.
—END OF PAPER—