0% found this document useful (0 votes)
4 views13 pages

Instructions To Students: NOT NOT

The document is an examination paper for CS1231 - Discrete Structures at the National University of Singapore, consisting of eight questions over ten pages. It includes instructions for students, such as writing their student number and answering all questions, with specific mathematical problems related to functions, set theory, and graph theory. The paper is open book and allows the use of 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)
4 views13 pages

Instructions To Students: NOT NOT

The document is an examination paper for CS1231 - Discrete Structures at the National University of Singapore, consisting of eight questions over ten pages. It includes instructions for students, such as writing their student number and answering all questions, with specific mathematical problems related to functions, set theory, and graph theory. The paper is open book and allows the use of 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/ 13

CS1231

NATIONAL UNIVERSITY OF SINGAPORE

CS1231 — DISCRETE STRUCTURES


(Semester 2: AY2023/24)

Time allowed: 2 hours

INSTRUCTIONS TO STUDENTS STUDENT NUMBER


1. Do NOT turn over this cover page and do A
NOT start writing until your invigilator tells U 0 0 0 0 0 0 0 A N

you to do so. A 1 1 1 1 1 1 1 B R
HT 2 2 2 2 2 2 2 E U
2. On the right, write down your Student Number NT 3 3 3 3 3 3 3 H W

and, for each digit or letter in there, shade the 4 4 4 4 4 4 4 J X


5 5 5 5 5 5 5 L Y
corresponding circle COMPLETELY in the
6 6 6 6 6 6 6 M
grid using ink or pencil. 7 7 7 7 7 7 7
8 8 8 8 8 8 8
3. Do not write your name.
9 9 9 9 9 9 9

4. This assessment paper contains EIGHT ques-


tions. It comprises TEN pages excluding this
cover page. Examiner’s use only

5. Answer ALL questions. Question Marks

6. Write your answers in the spaces provided. 1


7. If you need extra space for your answers, then 2
use the back cover.
8. You may leave your numerical answers as prod- 3
ucts and quotients of expressions of the form
r n
 4
n, n , P (n, r), n! or r where n, r ∈ N.
9. This is an OPEN BOOK assessment. You 5
may refer to any materials on physical paper.
6
10. The use of handheld calculators is allowed.
7

Total
CS1231

1. For r ∈ R+ , denote by I(r) the closed interval {a ∈ R : −r ⩽ a ⩽ r}. Define

A = {(s, s2 ) : s ∈ I(4)} and B = {(t4 − t2 , t3 − t) : t ∈ I(2)}.

Consider the relation f from A to B defined by

f = (2t, 4t2 ), (t4 − t2 , t3 − t) : t ∈ I(2) .


 

(i) Prove that f is a function A → B. [5 marks]


Solution. (F1) Take any (s, s2 ) ∈ A, where s ∈ I(4). Then −4 ⩽ s ⩽ 4 by the definition
of I(4). Let t = s/2. Then s = 2t and −2 ⩽ t ⩽ 2. So t ∈ I(2). Thus (t4 − t2 , t3 − t) ∈ B and

(s, s2 ), (t4 − t2 , t3 − t) = (2t, 4t2 ), (t4 − t2 , t3 − t) ∈ f


 

by the definition of f .

(F2) Let x ∈ A and y1 , y2 ∈ B satisfying (x, y1 ), (x, y2 ) ∈ f . Then the definition of f gives
t1 , t2 ∈ I(2) such that

(x, y1 ) = (2t1 , 4t1 2 ), (t1 4 − t1 2 , t1 3 − t1 ) and (x, y2 ) = (2t2 , 4t2 2 ), (t2 4 − t2 2 , t2 3 − t2 ) .


 

Looking at the first coordinates, we see (2t1 , 4t1 2 ) = x = (2t2 , 4t2 2 ). This implies 2t1 = 2t2 ,
and thus t1 = t2 . It follows that

y1 = (t1 4 − t1 2 , t1 3 − t1 ) = (t2 4 − t2 2 , t2 3 − t2 ) = y2 .

1
CS1231

1. (Cont’d from the previous page)


(ii) Is f surjective? Prove that your answer is correct. [3 marks]
Solution. Yes, as shown below.

Let (t4 − t2 , t3 − t) ∈ B, where t ∈ I(2). Define s = 2t. As −2 ⩽ t ⩽ 2, we know −4 ⩽ s ⩽ 4.


So (s, s2 ) ∈ A and
f (s, s2 ) = f (2t, 4t2 ) = (t4 − t2 , t3 − t).

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


Solution. No, as shown below.

Note that

f (2, 4) = f (2 × 1, 4 × 12 ) = (14 − 12 , 13 − 1) = (0, 0)


= (−1)4 − (−1)2 , (−1)3 − (−1) = f 2 × (−1), 4 × (−1)2 = f (−2, 4),
 

but (2, 4) ̸= (−2, 4).

Diagrams (extra).
s = −4 s=4 t=2

A t = −2

2
CS1231

2. (a) Is it true that, for all sets A and B, every function f : A → B, when considered as a subset
of A × B, has the same cardinality as its domain A? Prove that your answer is correct.
[4 marks]
Solution. Yes, as shown below.

Define g : A → f by setting g(x) = (x, f (x)) for each x ∈ A.

(Surjectivity) Let (x, y) ∈ f . Then y = f (x) and thus g(x) = (x, f (x)) = (x, y).

(Injectivity) Let x1 , x2 ∈ A such that g(x1 ) = g(x2 ). Then (x1 , f (x1 )) = (x2 , f (x2 )) by the
definition of g. This implies x1 = x2 .

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

Alternative proof. Define h : f → A by setting h(x, y) = x for each (x, y) ∈ A.

(Surjectivity) Let x ∈ A. Then (x, f (x)) ∈ f and h(x, f (x)) = x.

(Injectivity) Let (x1 , y1 ), (x2 , y2 ) ∈ f such that h(x1 , y1 ) = h(x2 , y2 ). Then x1 = x2 by the
definition of h. Also y1 = f (x1 ) = f (x2 ) = y2 . So (x1 , y1 ) = (x2 , y2 ).

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

(b) Is it true that, for all sets A and B, every function f : A → B, when considered as a subset
of A × B, has the same cardinality as its codomain B? Prove that your answer is correct.
[4 marks]
Solution. No, as shown below.

Consider A = {−1, 1} and B = {0}. Define f : A → B by setting f (−1) = 0 = f (1). Then


|f | = |{(−1, 0), (1, 0)}| = 2 ̸= 1 = |{0}| = |B|. So f does not have the same cardinality
as B.

3
CS1231

3. Is it true that, for all sets A, if there is a surjection f from A to some countable set B, then A is
countable? Prove that your answer is correct. [4 marks]
Solution. No, as shown below.

Consider the function f : P(N) → {1} such that f (x) = 1 for every x ∈ P(N). This is a surjection
because ∅ ∈ P(N) and f (∅) = 1. Now {1} is a finite set, as witnessed by id{1} . So it is countable
by Proposition 9.1.3. However, we know from Corollary 9.3.2 that P(N) is uncountable.

4. There are 30 sets, of which 20 are countable and 24 are infinite. How many of them are both
countable and infinite? Explain your answer. [3 marks]
Solution. Let C be the set of all countable sets and I be the set of all infinite sets here. Note
that all sets are either countable or infinite because finite sets are countable by Proposition 9.1.3.
So |C ∪ I| = 30. Also, by the Inclusion–Exclusion Rule,

|C ∪ I| = |C| + |I| − |C ∩ I|
= 20 + 24 − |C ∩ I|.

Hence, the number of sets that are both countable and infinite here is

|C ∩ I| = 20 + 24 − |C ∪ I| = 20 + 24 − 30 = 14.

Alternative solution. There are 30 sets, of which 24 are infinite. So the Difference Rule tells us
30 − 24 = 6 of these are finite. All these 6 sets are countable in view of Proposition 9.1.3. The
rest are infinite. Since there are 20 countable sets here, the number of countable infinite sets here
is 20 − 6 = 14 by the Difference Rule.

4
CS1231

5. The following is a drawing of a tree T with root r.

Calculate the number of subgraphs of T that satisfy all of the following: (a) it contains the vertex r,
(b) when r is considered the root, it has height 3 and all parents have exactly two children, and
(c) when r is considered the root, all the terminal vertices of the subgraph are terminal vertices of T .
Show your working, where it is indicated where each term comes from. [2 marks]
Solution.
• There is 1 way to choose top vertex r.

• There are 42 ways to choose the two children of the root.




• For each of these 2 children, there are 32 ways to choose its two children.


• For each of these 2 × 2 = 4 children, there are again 32 ways to choose its two children.


By the General Multiplication Rule, the number of such sequences of choices is


  2  4
4 3 3 4×3
= × 32 × 34 = 4374.
2 2 2 2×1

Each such sequence of choices gives rise to a required subgraph, and each required subgraph is
constructed from exactly one such sequence of choices. Therefore, the number of such graphs is
also 4374.

5
CS1231

6. The following is a drawing of a graph G.

1
2 3
4 5 6 7

Calculate the number of graphs that satisfy all of the following: (a) it is isomorphic to G, and
(b) it has the same vertices as G. Show your working, where it is indicated where each term comes
from. [2 marks]
Solution.
• There are 7 ways to choose a new label x1 ∈ {1, 2, . . . , 7} for the vertex that is labelled 1
in G.
• There are 7 − 1 = 6 ways to choose a new label x2 ∈ {1, 2, . . . , 7} \ {x1 } for the vertex that
is labelled 2 in G.
• There are 7 − 2 = 5 ways to choose a new label x3 ∈ {1, 2, . . . , 7} \ {x1 , x2 } for the vertex
that is labelled 3 in G.
• ...

• There are 7 − 6 = 1 ways to choose a new label x7 ∈ {1, 2, . . . , 7} \ {x1 , x2 , . . . , x6 } for the
vertex that is labelled 7 in G.
By the General Multiplication Rule, the number of such sequences of choices is 7 × 6 × · · · × 1 = 7!.
Each such sequence of choices gives rise to a required graph, and each required graph is constructed
from exactly 8 such sequences:

a a a a
b c b c b c b c
de f g de gf ed f g ed gf
a a a a
c b c b c b c b
f g de gf de f g ed gf ed

are drawings of the same graph. Therefore, the number of such graphs is 7!/8 = 630.

Alternative solution.
• There are 7 ways to choose a new label x1 ∈ {1, 2, . . . , 7} for the vertex that is labelled 1
in G.
• There are 7−1 = 62 ways to choose a subset {x2 , x3 } ⊆ {1, 2, . . . , 7} \ {x1 } of new labels
 
2
for the set {2, 3} of vertices in G, where x2 < x3 .
• There are 6−2 = 42 ways to choose a subset {x4 , x5 } ⊆ {1, 2, . . . , 7} \ {x1 , x2 , x3 } of size 2
 
2
to make edges x2 x4 and x2 x5 .
• There are 4−2 = 22 ways to choose a set {x6 , x7 } ⊆ {1, 2, . . . , 7} \ {x1 , x2 , . . . , x5 } of size 2
 
2
to make edges x3 x6 and x3 x7 .
By the General Multiplication Rule, the number of such sequences of choices is 7 × 62 × 42 × 22 =
  

630. Each such sequence of choices gives rise to a required graph, and each required graph is
constructed from exactly one such sequence. Therefore, the number of such graphs is also 630.

5
CS1231

7. Consider the undirected graph G where

V(G) = {2, 4, 5, 7, 8}, and


E(G) = {ab : a, b ∈ V(G), and either a + 4 < b or b + 4 < a}.

(i) Draw G. Label the vertices in your drawing. [1 mark]


Solution. 7—2—8 4 5

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


Solution. 3.

(iii) What is the length of the longest path in G? [1 mark]


Solution. 2.

6
CS1231

8. A tuberoot is defined to be a connected loopless undirected finite graph in which no two distinct
cycles share a common vertex. Here are drawings of two tuberoots.

• • • • • •
• • • • •
• • •

• • • • • •

The following are not drawings of tuberoots.

• • • • • •
• • • • •
• • •

• • • • • •

(i) How many tuberoots are there with exactly 7 vertices and exactly 2 cycles if we count isomorphic
tuberoots as one? Explain your answer. [3 marks]
Solution. There are exactly 4, as listed below.
• • • • • • • •
• • • • • • • • • •
• • • • • • • • •

For each cycle C in a tuberoot G, define the undirected graph G ◁ C as follows:

V(G ◁ C) = (V(G) \ V(C)) ∪ {˚}, where ˚ is a new vertex;


E(G ◁ C) = {e ∈ E(G) : e ∩ V(C) = ∅} ∪ {˚b : b ̸∈ V(C) and ab ∈ E(G) for some a ∈ V(C)}.

(ii) The following is a drawing of a tuberoot G.

e b
d a
f c i j
h g

Draw G ◁ C, where C is the cycle abca. [1 mark]


Solution.
e
d ˚
f i j
h g

7
CS1231

8. (Cont’d from the previous page)


(iii) Let G be a tuberoot and C be a cycle in G. Prove that G ◁ C is connected. [4 marks]
Solution. Pick any u, v ∈ V(G ◁ C).

Case 1: suppose u, v ∈ V(G) \ V(C). Use the connectedness of G to find a path P =


x0 x1 . . . xn in G where x0 = u and xn = v.
Case 1.1: suppose V(P ) ∩ V(C) = ∅. Then P is a path in G ◁ C in view of the definition
of G ◁ C.
Case 1.2: suppose V(P ) ∩ V(C) ̸= ∅. We claim that V(P ) ∩ V(C) = {xi , xi+1 , . . . , xi+s }
and E(P ) ∩ E(C) = {xi xi+1 , xi+1 xi+2 , . . . , xi+s−1 xi+s } for some i, s ∈ N satisfying
0 ⩽ i ⩽ i + s ⩽ n. Suppose not. Invoke the Well-Ordering Principle to find i, j, s, t ∈ N
with i ⩽ i + s < j ⩽ j + t such that

xi xi+1 , xi+1 xi+2 , . . . , xi+s−1 xi+s ∈ E(C) and


xi+s xi+s+1 , xi+s+1 xi+s+2 , . . . , xj−1 xj ̸∈ E(C) and
xj xj+1 , xj+1 xj+2 , . . . , xj+t−1 xj+t ∈ E(C).

Say C = z1 z2 . . . zℓ z1 , where z1 = xj and zr = xi+s , and z1 z2 ̸∈ E(P ). Note that


xi+s xi+s+1 ∈ E(P ) \ E(C) and zr−1 zr ∈ E(C), where xi+s = zr . So xi+s , xi+s+1 , zr−1
must be three different vertices. This tells us that

xi+s xi+s+1 . . . xj−1 xj z2 z3 . . . zr

is a cycle in G. It is distinct from C, because it contains the edge xi+s xi+s+1 ̸∈ E(C),
but it shares the vertex xi+s with C. This contradicts the fact that G is a tuberoot,
and thus proves the claim.
...

z2 ...
x
xi i+s z1
u = x0 ... xn = v
zr xj xj+t P
...
C ...
Use the claim to obtain i, s ∈ N such that 0 ⩽ i ⩽ i + s ⩽ n and V(P ) ∩ V(C) =
{xi , xi+1 , . . . , xi+s }. Notice x0 = u ̸∈ V(C) and xn = v ̸∈ V(C). Since xi , xi+s ∈ V(C),
actually 0 < i ⩽ i + s < n. So x0 x1 . . . xi−1 ˚xi+s+1 xi+s+2 . . . xn is a path between u
and v in G ◁ C.
Case 2: suppose exactly one of u, v is in V(G)\V(C). Say u ∈ V(G)\V(C) and v = ˚. In
view of the connectedness of G, there is a path in G between u and some vertex in C. Use the
Well-Ordering Principle to find such a path P = x0 x1 . . . xn of shortest length, where x0 = u
and xn ∈ V(C). By the minimality of the length of P , we know x0 , x1 , . . . , xn−1 ̸∈ V(C).
Then x0 x1 . . . xn−1 ˚ is a path in G ◁ C between u and v by the definition of G ◁ C.

Case 3: suppose u, v ̸∈ V(G) \ V(C). Then u = ˚ = v by the definition of G ◁ C. So ˚ is


a path between u and v in G ◁ C.

In all cases, we have a path between u and v in G ◁ C.

8
CS1231

8. (Cont’d from the previous page)


(iv) Let G be a tuberoot and C be a cycle in G. Prove that the cycles in G ◁ C are precisely the
cycles in G excluding C. [3 marks]
Solution. Only vertices in C and edges containing a vertex in C are affected in the construc-
tion of G ◁ C from G. As no distinct cycles share a common vertex in the tuberoot G, the
graph G ◁ C inherits all the cycles in G except C.

Let D be any cycle in G ◁ C.


Case 1: suppose ˚ ̸∈ V(D). Then D is actually a cycle in G because all the new edges
added when constructing G ◁ C from G contain ˚. Since G ◁ C no longer has the
vertices (and the edges) in C, we know D ̸= C.
Case 2: suppose ˚ ∈ V(D). Say D = b1 b2 . . . bm b1 , where b1 = ˚ and ℓ ⩾ 3. This tells us
b2 ̸= bm and ˚b2 , ˚bm ∈ E(G ◁ C). Use the definition of G ◁ C to find a2 , am ∈ V(C)
such that a2 b2 , am bm ∈ E(G). Say C = z1 z2 . . . zℓ z1 , where z1 = am and zk = a2 . Now
a2 , b2 , bm are three distinct vertices. So a2 b2 b3 . . . bm am z2 z3 . . . zk is a cycle in G. It is
distinct from C because it contains the vertex b2 , but it shares the vertex a2 with C.
This contradicts the hypothesis that G is a tuberoot.

(v) Let G be a tuberoot and C be a cycle in G. Explain why

|V(G ◁ C)| = |V(G)| − |V(C)| + 1 and |E(G ◁ C)| = |E(G)| − |E(C)|.

[2 marks]
Solution. By the Difference Rule and the Addition Rule,

|V(G ◁ C)| = |(V(G) \ V(C)) ∪ {˚}| = |V(G)| − |V(C)| + |{˚}| = |V(G)| − |V(C)| + 1.

When constructing G ◁ C from G, all the edges in C are removed, and each edge ab ∈ E(G)
where a ∈ V(C) and b ̸∈ V(C) is replaced by an edge ˚b ∈ E(G ◁ C). We show that this
replacement process is injective, which will imply

|E(G)| = |{e ∈ E(G) : e ∩ V(C) = ∅}| + |{e ∈ E(G) : |e ∩ V(C)| = 1}|


+ |{e ∈ E(G) : e ⊆ V(C)}|
= |{e ∈ E(G) : e ∩ V(C) = ∅}|
+ |{˚b ∈ E(G) : b ̸∈ V(C) and ab ∈ E(G) for some a ∈ V(C)}|
+ |{e ∈ E(G) : e ⊆ V(C)}|
= |E(G ◁ C)| + |E(C)|

by the Addition Rule and the definition of G ◁ C, and thus |E(G ◁ C)| = |E(G)| − |E(C)|.

Let a1 , a2 ∈ V(C) and b1 , b2 ∈ V(G) \ V(C) such that a1 b1 , a2 b2 ∈ E(G) and ˚b1 = ˚b2 .
Then b1 = b2 because b1 ̸= ˚ ̸= b2 . Suppose a1 ̸= a2 . Say C = z1 z2 . . . zℓ z1 , where z1 = a1
and zk = a2 . Note that a1 , a2 , b1 are three different vertices. So b1 z1 z2 . . . zk b2 is a cycle in G.
It is distinct from C because it contains the vertex b1 , but it shares the vertex a1 with C.
This contradicts the hypothesis that G is a tuberoot.

9
CS1231

8. (Cont’d from the previous page)


(vi) Prove by induction on the number c of cycles in G that, for every tuberoot G,

|E(G)| = |V(G)| − 1 + c.

[4 marks]
Solution. (Base step) Let G be a tuberoot with no cycle. By the definition of tuberoots,
we know G is loopless and connected. So G is acyclic and is thus a tree. It follows from
Theorem 12.1.10 that |E(G)| = |V(G)| − 1 = |V(G)| − 1 + 0.

(Induction step) Let k ∈ N such that the proposition is true for all tuberoots with exactly
k cycles. Consider a tuberoot G with exactly k + 1 cycles. Pick any cycle C in G. We know
from (iii) that G ◁ C is connected. Since G has no loop and the construction of G ◁ C does
not introduce any loop, we know that G ◁ C is again loopless. Being a tuberoot, no distinct
cycles in G share a common vertex. Since all cycles in G ◁ C are cycles in G by (iv), the same
is true in G ◁ C. Therefore, we deduce that G ◁ C is a tuberoot. By (iv) again, the tuberoot
G ◁ C has exactly one fewer cycles than G. So G ◁ C has exactly k cycles. The induction
hypothesis then tells us |E(G ◁ C)| = |V(G ◁ C)| − 1 + k. By this and (v),

|E(G)| = |E(G ◁ C)| + |E(C)| = |V(G ◁ C)| − 1 + k + |E(C)|


= |V(G)| − |V(C)| + 1 − 1 + k + |E(C)| = |V(G)| − 1 + (k + 1).

Alternative way to complete the induction step. Let k ∈ N such that the proposition is
true for all tuberoots with exactly k cycles. Consider a tuberoot Gk+1 with exactly k+1 cycles.
Pick any cycle C in Gk+1 . Take e ∈ E(C). Let Gk be the graph obtained from Gk+1 by
removing the edge e, i.e.,

V(Gk ) = V(Gk+1 ) and E(Gk ) = E(Gk+1 ) \ {e}.

As Gk+1 is a connected and e comes from a cycle in Gk+1 , we can show that Gk is connected
by following the proof of Theorem 12.1.4. As Gk is a subgraph of the loopless graph Gk+1
where no two distinct cycles share a common vertex, we know Gk also has no loop, and no
two distinct cycles in Gk share a common vertex too. These show that Gk is a tuberoot.

Now we count the number of cycles in Gk . In the construction from Gk+1 to Gk , only vertices
and edges in C are affected. As no distinct cycles share a common vertex in the tuberoot Gk+1 ,
the graph Gk inherits all the cycles in Gk+1 except C. Conversely, all cycles in Gk are cycles
in Gk+1 because Gk is a subgraph of Gk+1 . So the cycles in Gk are precisely the cycles
in Gk+1 excluding C. As Gk+1 has k + 1 cycles, we deduce that Gk has k cycles. Hence

|E(Gk+1 )| = |E(Gk )| + |{e}| by the Addition Rule;


= |E(Gk )| + 1
= |V(Gk )| − 1 + k + 1 by the induction hypothesis;
= |V(Gk+1 )| − 1 + (k + 1).

END OF PAPER

10
CS1231

Use this page if and only if you need extra space for your answers, in which case (1) indicate the question
number(s) clearly below, and (2) indicate in the original answer space that you are using this page for
that question. Do not use this space for rough work.

This page is intentionally left blank.

You might also like