Vous êtes sur la page 1sur 7

NATIONAL UNIVERSITY OF SINGAPORE

SCHOOL OF COMPUTING

EXAMINATION FOR
SEMESTER 2 AY 2008/2009

CS1231 - DISCRETE STRUCTURES

Apr/May 2009 Time allowed: 2 hours

INSTRUCTIONS TO CANDIDATES

1. This examination paper contains FOUR questions and comprises SIX printed pages,
including this page.

2. Answer ALL questions within the space in this booklet.

3. This is a Closed Book examination. Candidates are allowed to bring in an A4-sized


help sheet, written on both sides.

4. Please write your Matriculation Number below.

Matriculation NO:

Page Marks Remarks

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.

(1) Let S = {{∅}}. Find |P (S)|.

Soln: |S| = 1, {∅} being the only element of S. So |P (S)| = 21 = 2.

(2) Let B = {n ∈ Z : n = 3j + 2, j ∈ Z}, D = {n ∈ Z : n = 3j − 1, j ∈ Z}.

(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.

(6) Find 3101 Mod 98.

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

(7) Find d so that gcd(14039, 1529) = d.

Find s, t so that d = 14039s + 1529t.

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

139 = 1529 − 5 · 278 = 1529 − 5(14039 − 9 · 1529) = 46 · 1529 − 5 · 14039


PAGE 4 CS1231

(8) The integer 877 is prime if it has no prime divisor ≤ k. Find k.

List all primes ≤ k.

Is 877 a prime?

Soln: k = b 877c = 29.

The list: 2, 3, 5, 7, 11, 13, 17, 19, 23, 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

(10) Let G be the following graph:


a
• ......
............
.... . .....
...
...... ..... ........
.. .....
..... ... ..... .........
..... ... ..... ... ....
.... .. . .
b• ..... .
.

................................................................................... ......
.....
. .....
.....
.....
.....
..... ... ........
.
.
... .
.....
...
.
d
..... .. .....
............
• .......
c

(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.

Soln: acac, adac, abac, addc, acdc, adbc.

(b) Complete rows c and d of its adjacency and incidence matrices:

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

(12) Find the coefficient of a5 b7 in the expansion of (a − 2b)12 .


¡ ¢
Soln: 12 7
5 (−2) = −101376

(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

Edges of the tree:

Its weight:

Soln: Prim’s Algorithm:

The edges are picked in order:

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

Question B [10 marks]. Prove the following by mathematical induction.

6 | 7n − 1 ∀n ∈ Z∗ .

Soln: (Basis step: True for n = 0 (check this)

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

|A ∪ B ∪ C| = |S| − |C| + |A ∩ C| + |B ∩ C| − |A ∩ B ∩ C|.

Soln: Note that |A ∩ C| = |A| − |A ∩ C|, we have |(A ∩ B) ∩ C| = |A ∩ B| − |A ∩ B ∩ C|.


Thus

|A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ C| − |A ∩ B| − |B ∩ C| + |A ∩ B ∩ C|


= |S| − |C| + |A ∩ C| + |B ∩ C| − |A ∩ B ∩ C|

(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

Question D [15 marks]. Consider the function f : Z+ × Z+ → Z+ defined by


µ ¶
m+n−1
f (m, n) = + m.
2

(a) Compute the values f (1, n) for n = 1, 2, 3, 4. Ans:

(b) Compute the values of f (2, n) for n = 1, 2, 3, 4. Ans:

(c) Is the function onto? Justify your answer.


¡¢
Soln: Note that 12 = 0 as the number of ways to choose 2 objects from a set of 1
object is 0.

(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.

Alternatively, there is also a proof by induction.

Let P (k) be “ there exist m, n such that f (m, n) = k.

P (1) is certainly true since f (1, 1) = 1.

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.

Thus in both cases P (k + 1) is true. The proof is thus complete by mathematical


induction.

—END OF PAPER—

Vous aimerez peut-être aussi