0% found this document useful (0 votes)
9 views12 pages

Instructions To Students: NOT NOT

The document is an exam paper for CS1231 — Discrete Structures at the National University of Singapore for Semester 1: AY2023/24. It contains instructions for students, a series of mathematical questions related to functions, set theory, graph theory, and permutations, along with solutions and proofs for each question. The exam is open book and allows the use of handheld calculators.

Uploaded by

gordenpey
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)
9 views12 pages

Instructions To Students: NOT NOT

The document is an exam paper for CS1231 — Discrete Structures at the National University of Singapore for Semester 1: AY2023/24. It contains instructions for students, a series of mathematical questions related to functions, set theory, graph theory, and permutations, along with solutions and proofs for each question. The exam is open book and allows the use of handheld calculators.

Uploaded by

gordenpey
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/ 12

CS1231

NATIONAL UNIVERSITY OF SINGAPORE

CS1231 — DISCRETE STRUCTURES


(Semester 1: AY2023/24)

Time allowed: 2 hours

Student Number:

A
Examiner’s use only

Question Marks
INSTRUCTIONS TO STUDENTS
1
1. Do NOT turn over this cover page and do NOT
start writing until your invigilator tells you to do 2
so.
3
2. Write your Student Number only. Do not write
your name. 4
3. This exam paper contains SEVEN questions. It 5
comprises TEN pages excluding this cover page.
4. Answer ALL questions. 6

5. Write your answers in the spaces provided. 7


6. This is an OPEN BOOK assessment. You may Total
refer to any materials on physical paper.
7. The use of handheld calculators is allowed.
CS1231

1. Consider the relation f from N to N defined by

f = {(n, x) ∈ N2 : x2 ⩽ n < (x + 1)2 }.

In this question, you may use without proof the fact that, for all x, y ∈ N, if x < y, then x2 < y 2 .

(i) Prove by induction that, for all n ∈ N, there exists x ∈ N such that (n, x) ∈ f . [4 marks]
2 2
Solution. (Base step) Note that 0 ⩽ 0 < 1 . So (0, 0) ∈ f .

(Induction step) Let k ∈ N such that some x0 ∈ N makes (k, x0 ) ∈ f . Fix such an x0 ∈ N.
Then x0 2 ⩽ k < (x0 + 1)2 by the definition of f . As k ∈ N, this implies k ⩽ (x0 + 1)2 − 1.
Case 1: suppose k < (x0 + 1)2 − 1. Then

x0 2 ⩽ k < k + 1 < (x0 + 1)2 − 1 + 1 = (x0 + 1)2 .

So (k + 1, x0 ) ∈ f .

Case 2: suppose k = (x0 + 1)2 − 1. Since x0 + 1 ⩾ 0 + 1 = 1,

(x0 + 1)2 < (x0 + 1)(x0 + 2) < (x0 + 2)2 .

As k + 1 = (x0 + 1)2 , this implies (x0 + 1)2 ⩽ k + 1 < (x0 + 2)2 . So (k + 1, x0 + 1) ∈ f .

Hence, in all cases, some x ∈ N makes (k + 1, x) ∈ f .

(ii) Prove that f is a function N → N. [4 marks]


Solution. (F1) This is given by (i).

(F2) Let n, x1 , x2 ∈ N such that (n, x1 ), (n, x2 ) ∈ f . Then the definition of f tells us

x1 2 ⩽ n < (x1 + 1)2 and x2 2 ⩽ n < (x2 + 1)2 .


∴ x1 2 ⩽ n < (x2 + 1)2 and x2 2 ⩽ n < (x1 + 1)2 .
∴ x1 < x2 + 1 and x2 < x1 + 1.
∴ x1 ⩽ x2 and x2 ⩽ x1 as x1 , x2 ∈ N.
∴ x1 = x2 .

Alternative proof for (F2). We prove the contrapositive. Let n, x1 , x2 ∈ N such that
x1 ̸= x2 . Say x1 < x2 . Since x1 , x2 ∈ N, this implies x1 + 1 ⩽ x2 . We want to show that
(n, x1 ) ̸∈ f or (n, x2 ) ̸∈ f .

Case 1: suppose (n, x1 ) ̸∈ f . Then we already have what we want.


Case 2: suppose (n, x1 ) ∈ f . Then the definition of f tells us x1 2 ⩽ n < (x1 + 1)2 . This
implies n < (x1 + 1)2 ⩽ x2 2 . So (n, x2 ) ̸∈ f in view of the definition of f .
Therefore, we have what we want in all cases.

1
CS1231

1. (Cont’d from the previous page)


(iii) Work out the value of (f ◦ f )(31)? Explain your working. [3 marks]
Solution. Note that 52 = 25 ⩽ 31 < 36 = (5 + 1)2 and 22 = 4 ⩽ 5 < (2 + 1)2 . So the
definition of f implies f (31) = 5 and (f ◦ f )(31) = f (f (31)) = f (5) = 2.

(iv) Is f surjective? Prove that your answer is correct. [3 marks]


Solution. Yes, as shown below.

Let x ∈ N. Then x2 ⩽ x2 < (x + 1)2 . So f (x2 ) = x.


Alternative proof. Let x ∈ N. Then x2 ⩽ x2 + 2x < x2 + 2x + 1 = (x + 1)2 . So
f (x2 + 2x) = x.

(v) Is f injective? Prove that your answer is correct. [3 marks]


Solution. No, as shown below.

Consider 1, 2 ∈ N. Note that 12 = 1 ⩽ 1 < 4 = (1 + 1)2 and 12 = 1 ⩽ 2 < 4 = (1 + 1)2 . So


f (1) = 1 = f (2), although 1 ̸= 2.

2
CS1231

2. Let A = {x ∈ R : x ⩽ 12} and B = {y ∈ R : y ⩾ 31}. Prove that A has the same cardinality
as B. [5 marks]
Solution. Define f : A → B by setting, for each x ∈ A,

f (x) = −x + 43.

(Well-definedness) Let x ∈ A. By the definition of A, we know x ⩽ 12. So −x+43 ⩾ −12+43 =


31. This means −x + 43 ∈ B.

(Surjectivity) Let y ∈ B. By the definition of B, we know y ⩾ 31. Define x = −y + 43. Then


x = −y + 43 ⩽ −31 + 43 = 12, and so x ∈ A. Also f (x) = −x + 43 = −(−y + 43) + 43 = y.

(Injectivity) Let x1 , x2 ∈ A such that f (x1 ) = f (x2 ). Then −x1 +43 = −x2 +43, and so x1 = x2 .

We see above that there is a bijection A → B. So A has the same cardinality as B.


Alternative proof of the bijectivity of f . Define g : B → A by setting, for each y ∈ B,

g(y) = −y + 43.

First, we verify that g is well defined. Let y ∈ B. By the definition of B, we know y ⩾ 31. So
−y + 43 ⩽ −31 + 43 = 12. This means −y + 43 ∈ A, as required.

Now, for all x ∈ A and all y ∈ B,

f (x) = y ⇔ −x + 43 = y by the definition of f ;


⇔ −y + 43 = x
⇔ g(y) = x by the definition of g.

So g = f −1 by Proposition 7.4.13. Hence, we know from Further Exercise 7.11 that f is bijective.

Diagram (extra materials). y

31–

x
p
12

3
CS1231

3. Prove that N × P(N) is uncountable. [3 marks]


Solution. Define f : P(N) → N × P(N) by setting, for each x ∈ P(N),

f (x) = (0, x).

(Injectivity) If x1 , x2 ∈ P(N) such that f (x1 ) = f (x2 ), then (0, x1 ) = (0, x2 ), and so x1 = x2 .

Recall from Corollary 9.3.2 that P(N) is uncountable. Since we have an injection f : P(N) →
N × P(N) where P(N) is uncountable, Proposition 9.2.5 tells us N × P(N) is uncountable too.
Alternative solution. Define g : N × P(N) → P(N) by setting, for each (n, x) ∈ N × P(N),

g(n, x) = x.

(Surjectivity) Let x ∈ P(N). Then g(0, x) = x by the definition of g.

Recall from Corollary 9.3.2 that P(N) is uncountable. Since we have a surjection g : N × P(N) →
P(N) where P(N) is uncountable, Proposition 9.2.5 tells us N × P(N) is uncountable too.

4. How many permutations of the string ELDERFLOWER are there? Justify your answer.
You may leave your answer as products and quotients of expressions of the form n, nr , P (n, r), n!
n

or r where n, r ∈ N. [3 marks]
Solution. Define Γ = {E1 , L1 , D, E2 , R1 , F, L2 , O, W, E3 , R2 }. In view of the General Multiplica-
tion Rule,
 
    number of
number of number of ways to



permutations = permutations of  × arrange 
 
of Γ ELDERFLOWER E1 , E2 , E3 into
3 positions
   
number of number of
ways to  ways to 
   
×  arrange  × arrange
 
.

L1 , L2 into  R1 , R2 into
2 positions 2 positions
 
number of
∴ 11! = permutations of  × 3! × 2! × 2! by Corollary 10.3.7.
EDLERFLOWER
11!
From this, we see that the number of permutations of ELDERFLOWER is 3! 2! 2! = 11!/24.
Alternative solution. The string ELDERFLOWER has 11 letters. So to form a permutation of
this string,

• there are 11

3 ways to choose the positions of the three E’s;

• there are 11−3 = 82 ways to choose the positions of the three L’s;
 
2

• there are 8−2 = 62 ways to choose the positions of the three R’s; and
 
2

• there are 4, 3, 2, 1 ways to choose the positions of D, F, O, W respectively.

Therefore, by the General Multiplication Rule, there are 11


 8 6
3 2 2 4! such permutations.

4
CS1231

5. The following is a drawing of an undirected graph G.

0 1 2 3 4 5 6 7

In this question, you may  leave your answers as products and quotients of expressions of the form
n, nr , P (n, r), n! or nr where n, r ∈ N.
(i) Calculate the number of graphs that satisfy all of the following: (a) have the same vertices
as G, and (b) are isomorphic to G. Explain your working. [2 marks]
Solution.

• There are 10 ways to choose the top vertex.


• There are 10 − 1 = 9 ways left to choose the bottom vertex.
• There are 9−1 = 84 ways left to choose 4 vertices that share an edge with the top
 
4
vertex.

• There are 44 = 1 way left to choose 4 vertices that share an edge with the bottom


vertex.
Each such choice gives the same graph as exactly one other choice. More specifically,

a b

c d e f g h i j and d c f e h g j i

b a

8

are the same graph. Therefore, the number of such graphs is 10 × 9 × 4 /2 = 3150.

(ii) Calculate the number of graphs that satisfy all of the following: (a) have the same vertices
as G, and (b) are isomorphic to G, and (c) have the vertex 0 in exactly 4 edges. Explain your
working. [2 marks]
Solution.
• Choose the top vertex to be 0.

• There are 10 − 1 = 9 ways left to choose the bottom vertex.


• There are 9−1 = 84 ways left to choose 4 vertices that share an edge with 0.
 
4

• There are 44 = 1 way left to choose 4 vertices that share an edge with the bottom


vertex.

By the General Multiplication Rule, the number of such graphs is 9 × 84 = 630.




5
CS1231

5. (Cont’d from the previous page)


(iii) Calculate the number of graphs that satisfy all of the following: (a) have the same vertices
as G, and (b) are isomorphic to G, and (c) have the vertices 0 and 1 both in exactly 4 edges.
Explain your working. [2 marks]
Solution.
• Choose the top vertex to be 0.

• Choose the bottom vertex to be 1.


• There are 10−2 = 84 ways left to choose 4 vertices that share an edge with 0.
 
4

• There are 8−4



4 = 1 way left to choose 4 vertices that share an edge with 1.

By the General Multiplication Rule, the number of such graphs is 84 = 70.




(iv) Calculate the number of graphs that satisfy all of the following: (a) have the same vertices
as G, and (b) are isomorphic to G, and (c) have the vertex 0 or the vertex 1 in exactly 4 edges.
Explain your working. [2 marks]
Solution. By symmetry, the number of graphs that have the same vertices as G and are
isomorphic to G and have the vertex 1 in exactly 4 edges is equal to the number of graphs
that have the same vertices as G and are isomorphic to G and have the vertex 0 in exactly
4 edges, and is thus equal to 630 by (ii). So the Inclusion–Exclusion Rule tells us
 
number of graphs that have the same vertices as G and are isomorphic
to G and have the vertex 0 or the vertex 1 in exactly 4 edges
   
number of graphs that number of graphs that
have the same vertices  have the same vertices 
   
= as G and are isomorphic  + as G and are isomorphic 
  

to G and have the  to G and have the 
vertex 0 in exactly 4 edges vertex 1 in exactly 4 edges
 
number of graphs that have the same vertices as G and are isomorphic

to G and have the vertex 0 and the vertex 1 both in exactly 4 edges
= 630 + 630 − 70 by (ii) and (iii)
= 1190.

6
CS1231

6. For a, b ∈ R, denote by Ia,b the closed interval {x ∈ R : a ⩽ x ⩽ b}. Consider the undirected graph G
where

V(G) = {I0,1 , I0,2 , I1,3 , I3,4 , I5,6 , I6,7 }, and



E(G) = AB : A, B ∈ V(G) and A ̸= B and A ∩ B ̸= ∅ .

(i) Draw G. Label the vertices in your drawing. [2 marks]


Solution. I0,2
I1,3 I3,4 I5,6 I6,7
I0,1

(ii) How many connected components does G have? [1 mark]


Solution. 2

(iii) Is G cyclic? Explain your answer. [2 marks]


Solution. Yes, because I0,1 I0,2 I1,3 I0,1 is a cycle in G.

7
CS1231

7. A multipus is defined to be a finite tree in which there is exactly one vertex that is in three or
more edges. This vertex is called the head of the multipus. For example, the left graph below is a
multipus, while the right one is not. The head is indicated by a filled circle in the multipus.

A tip of a multipus is a vertex that is in exactly one edge in the multipus. A span in a multipus
is a path between two different tips in the multipus. For example, the dashed lines below indicate
spans, while the dotted lines do not.

(i) How many multipuses are there with exactly 5 vertices if we count isomorphic multipuses as
one? Explain your answer. [2 marks]
Solution. There are 2, as listed below.

(ii) Calculate the number of spans in the following multipus. Explain your working. [2 marks]

h0
h1 h2
h

k1 k2
f1 f2

Solution. By definition, a span must be between two vertices that are both in exactly one
edge. There are exactly 5 such vertices in the given graph, namely h0 , h1 , h2 , f1 , and f2 . Any
two of these, i.e., any 2-combination of {h0 , h1 , h2 , f1 , f2 }, uniquely determine(s) a span in the
multipus by Proposition 12.1.3. Thus

number of spans in the multipus


= number of 2-combinations of {h0 , h1 , h2 , f1 , f2 }
 
|{h0 , h1 , h2 , f1 , f2 }|
=
2
 
5
=
2
5×4
= by Theorem 10.3.15;
2×1
= 10.

8
CS1231

7. (Cont’d from the previous page)


(iii) Prove that, for every multipus M with head h, the number t of tips in M is equal to the
number d of edges containing the head h in M . [2 marks]
Solution. Denote by j the number of vertices that are in exactly two edges in M . Then M
has exactly 1 + j + t vertices. As multipuses are trees, this implies M has exactly j + t edges
by Theorem 12.1.6. We count in two different ways the number of elements in

{(v, e) ∈ V(M ) × E(M ) : v ∈ e}.

• In view of the definition of multipuses, there are three mutually exclusively cases for
what the variable v can take.
(1) If the variable v takes the head h, then the variable e can take one of the d edges
that contains h.
(2) If the variable v takes a vertex that is in exactly two edges in M , then the variable e
can only take one of the two edges that contains v.
(3) If the variable v take a tip, then the variable e can only take the edge that con-
tains v.

So, by the Additional Rule and the General Multiplication Rule, there are exactly
1 × d + j × 2 + t × 1 = d + 2j + t ways to substitute objects into (v, e).
• The variable e can take one of j + t edges in M , and then the variable v can only take
one of the two vertices that are in e. So there are exactly (j + t) × 2 ways to substitute
objects into (v, e).

It follows that d + 2j + t = 2(j + t). Hence d = t.

Alternative solution. Work in M . Consider the following procedure.

1. Input an edge v0 v1 , where v0 = h.


2. Initialize i = 1.
// Note that vi is not the head here because there is no loop.
3. While vi is not a tip do:

3.1. Let vi vi+1 be an edge that is distinct from vi−1 vi .


// As vi is not the head and not a tip, it is in exactly two edges. So vi+1 is unique.
3.2. Increment i to i + 1.
// Note that vi is still not a head because otherwise v0 v1 . . . vi would be a cycle.

4. Output vi .
// This vi must be a tip for the while-loop to end.

This procedure defines a function from the set of all edges containing the head to the set of
all tips. In view of Theorem 8.3.1, it suffices to verify that this function is bijective.
(Surjectivity) Take any tip u. Use connectedness to get a path u0 u1 . . . uℓ where u0 = h
and uℓ = u. A run of the procedure above on input u0 u1 gives a tip vi , and in the process a
path v0 v1 . . . vi where v0 = u0 and v1 = u1 . Moreover, this procedure must give v2 = u2 , and
v3 = u3 , and . . . , until we get to vi = ui , where vi is a tip. However, the only tip in the path
u0 u1 . . . uℓ is uℓ . So ℓ = i and u = uℓ = ui = vi .
(Injectivity) Suppose this procedure gives output u on inputs v0 v1 and w0 w1 , where
v0 = h = w0 . Runs on these inputs give paths, say v0 v1 . . . vi and w0 w1 . . . wj respectively,
where vi = u = wj . Since these are two paths between h and u, they must be equal by
Proposition 12.1.3. In particular, we have v0 v1 = w0 w1 , as required.

9
CS1231

7. (Cont’d from the previous page)


(iv) Prove that, for every multipus M with head h, if all spans in M have length at most 2d − 2,
where d denotes the number of edges containing the head h in M , then there are two different
spans in M that have the same length. [3 marks]
Solution. Work in M . Between a tip u and the head h, there is a unique path by Theo-
rem 12.1.3, because M is tree; let us denote this unique path by Pu . From (iii), we know
there are exactly d tips. List without repetition the tips as u1 , u2 , . . . , ud such that the
lengths of Pu1 , Pu2 , . . . , Pud are non-decreasing. Denote by a1 , a2 , . . . , ad the lengths of the
paths Pu1 , Pu2 , . . . , Pud respectively. Observe that these paths do not share any vertex other
than the head h by Theorem 11.2.5 because M is acyclic.
Case 1: suppose some ai = ai+1 . Let Pui = v0 v1 . . . vai and Pui+1 = w0 w1 . . . wai , where
v0 = h = w0 and vai = ui and wai = ui+1 . As h is the head of the multipus, we know d ⩾ 3.
Find k ∈ {1, 2, . . . , d} \ {i, i + 1}. Let Puk = x0 x1 . . . xak , where x0 = h and xak = uk . Then
xak xak −1 . . . x1 hv1 v2 . . . vai and xak xak −1 . . . x1 hw1 w2 . . . wai are two different spans by the
observation above. Both of these spans have length ai + ak .
Case 2: suppose each ai < ai+1 . This means each ai+1 ⩾ ai +1 as these a’s are all integers.
Note that a1 ⩾ 1, because the head h is not a tip. So

ad−1 ⩾ ad−2 + 1 ⩾ (ad−3 + 1) + 1 = ad−3 + 2 ⩾ (ad−4 + 1) + 2 = ad−4 + 3 ⩾ · · ·


⩾ ad−(d−1) + (d − 1) − 1 = a1 + d − 2 ⩾ 1 + d − 2 = d − 1,

and ad ⩾ ad−1 + 1 ⩾ (d − 1) + 1 = d. Let Pud−1 = v0 v1 . . . vad−1 and Pud = w0 w1 . . . wad ,


where v0 = h = w0 and vad−1 = ud−1 and wad = ud . Then vad−1 vad−1 −1 . . . v1 hw1 w2 . . . wad
is a span by the observation above. This span has length ad−1 + ad ⩾ (d − 1) + d = 2d − 1,
contradicting the condition that all spans have length at most 2d − 2. Therefore, this case is
not possible.
Extra explanation for the observation used above. Let Pui = v0 v1 . . . vai and Puj =
w0 w1 . . . waj , where i ̸= j and v0 = h = w0 and vai = ui and waj = uj . As the head h is not
a tip, we have ai ⩾ 1 and aj ⩾ 1. Some vp ̸= wp because otherwise:
• if ai = aj , then ui = vai = vaj = waj = uj , which contradicts the condition that the list
u1 , u2 , . . . , ud has no repetition;
• if ai < aj , then wai −1 wai and wai wai +1 are different edges containing wai = vai = ui ,
which is impossible because ui is a tip; and
• if aj < ai , then vaj −1 vaj and vaj vaj +1 are different edges containing vaj = waj = uj ,
which is impossible because uj is a tip.
Use the Well-Ordering Principle to find the smallest p ∈ {0, 1, . . . , ai } such that vp ̸= wp . As
v0 = h = w0 , we know p ⩾ 1. Hence, by the smallestness of p, we have vp−1 = wp−1 .

Case 1: suppose p − 1 ⩾ 1. By the smallestness of p, we again have vp−2 = wp−2 . Note that
vp−2 vp−1 and vp−1 vp and wp−1 wp are three different edges that contain vp−1 = wp−1 .
So vp−1 = wp−1 must be the unique head h.
Case 2: suppose p − 1 = 0. Then vp−1 = v0 = h = w0 = wp−1 .

So vp−1 = v0 = h = w0 = wp−1 in all cases. If we have non-zero r, s such that vr = ws , then,


since v1 = vp ̸= wp = w1 ,
hv1 v2 . . . vr and hw1 w2 . . . ws
are distinct paths between h and vr = ws , which contradicts Proposition 12.1.3. Hence no
non-zero r, s make vr = ws . This tells us that Pui and Puj do not share any vertex other than
the head h. ■

10
CS1231

7. (Cont’d from the previous page)

(iv) Alternative solution. Work in M . On the one hand, since the head is not a tip, any span
must have at least three vertices (i.e., the head and two different tips), and thus at least
two edges by Further Exercise 11.7. On the other hand, by assumption, all spans have at
most 2d − 2 edges. So the length of a span must be amongst 2, 3, 4, . . . , 2d − 2. There are
(2d − 2) − 2 + 1 = 2d − 3 such numbers.
Recall that d ⩾ 3 by the definition of heads and multipuses. Split into two cases.
Case 1: suppose d = 3. Then M must be isomorphic to one of the following multipuses.

v1 v1 v1 v1 v1
u u u u u
v2 v2 v2 v2 v2

In each of these cases, there are two different spans of the same length, one between u and v1 ,
and the other between u and v2 .
Case 2: suppose d ⩾ 4. A span is uniquely determined by the two different  tips it contains.
From (iii), we know there are exactly d tips. Therefore, there are exactly d2 spans. We know
d − 2 > d − 3 ⩾ 4 − 3 = 1 > 0 as d ⩾ 4. So 0 < (d − 2)(d − 3) = d2 − 5d + 6 = (d2 − d) − (4d − 6).
This implies
d2 − d
 
4d − 6 d(d − 1) d
2d − 3 = < = = .
2 2 2 2
This tells us there are strictly fewer lengths than there are spans. So there must be two spans
that have the same length by the Pigeonhole Principle.

Extra explanation for the application of the Pigeonhole Principle. For this appli-
cation, we are considering the function f : A → B, where A is the set of all spans, and
B = {2,3, 4, . . . , 2d − 2}, and where f (S) is the length of S for all spans S. We saw that
|A| = d2 > 2d − 3 = |B|. So the Pigeonhole Principle tells us that f is not injective. This
non-injectivity gives distinct spans S1 , S2 satisfying f (S1 ) = f (S2 ), i.e., two distinct spans
that have the same length. ■

END OF PAPER

11

You might also like