cs1231s Exam21s2 Qns
cs1231s Exam21s2 Qns
INSTRUCTIONS
1. This assessment paper contains TWENTY ONE (21) questions in THREE (3) parts and comprises
TWELVE (12) printed pages. The last two pages are intentionally left blank.
2. This is an OPEN BOOK assessment.
3. Printed/written materials are allowed. Apart from calculators, electronic devices are not
allowed.
4. Answer ALL questions and write your answers only on the ANSWER SHEETS provided.
5. Do not write your name on the ANSWER SHEETS.
6. The maximum mark of this assessment is 100.
Question Max. mark
Part A: Q1 – 10 20
Part B: Q11 – 16 18
Part C: Q17 5
Part C: Q18 10
Part C: Q19 20
Part C: Q20 20
Part C: Q21 7
Total 100
2. Aiken is taking the CS1231S final exam which consists of the dreadful MRQs (multiple-response
questions). If each MRQ has 5 options A, B, C, D and E, in how many ways can Aiken write his
answer for each MRQ, assuming that he writes at least one option in his answer. Note that the
order of the options in his answer does not matter, for example, ABC, ACB and BCA are considered
the same answer.
A. 31.
B. 32.
C. 325.
D. 3125.
E. None of the above.
4. Given that ∀𝑥 ∃𝑦 𝑃(𝑥, 𝑦) is true on a non-empty domain of discourse, which of the following
statements is true?
A. ∃𝑦 ∀𝑥 𝑃(𝑥, 𝑦)
B. ∃𝑥 ∃𝑦 𝑃(𝑥, 𝑦)
C. ∀𝑥 ∀𝑦 𝑃(𝑥, 𝑦)
D. ∃𝑥 ∀𝑦 ~𝑃(𝑥, 𝑦)
E. None of the above.
- 2 of 12 -
CS1231S
5. Define a set 𝑆 recursively as follows.
(1) 5 ∈ 𝑆. (base clause)
(2) If 𝑥 ∈ 𝑆, then 𝑥 + 3 ∈ 𝑆 and 𝑥 + 5 ∈ 𝑆. (recursion clause)
(3) Membership for 𝑆 can always be demonstrated by (finitely many)
successive applications of clauses above. (minimality clause)
What is the smallest integer 𝑘 such that all integers 𝑛 ≥ 𝑘 are in 𝑆?
A. 7.
B. 8.
C. 9.
D. 10.
E. None of the above.
- 3 of 12 -
CS1231S
8. Given 𝐴 = {1,2,3,4,5} and the partial order 𝑅 on 𝐴 as follows:
𝑅 = {(𝑥, 𝑥) ∶ 𝑥 ∈ 𝐴} ∪ {(2,1), (2,5), (3,1), (3,2), (3,4), (3,5), (4,1)}
How many distinct linearizations of 𝑅 are there?
A. 3
B. 5
C. 7
D. 12
E. None of the above.
9. Aiken working on a problem from circuit design came up with a graph G, while Dueet working on
a problem from computational biology came up with a graph G*. When they met for dinner, they
were surprised to find that that G and G* are isomorphic. Aiken’s graph G has 6 connected
components.
How many connected components are there in G*?
A. G* has at most 6 connected components.
B. G* has at least 6 connected components.
C. G* has at exactly 6 connected components.
D. G* does not have exactly 6 connected components.
E. There is insufficient information to determine.
10. Given the following directed graph 𝐺 = (𝑉, 𝐸), how many walks of length 3 in total are there
between 𝑢 and 𝑤, ∀𝑢, 𝑤 ∈ 𝑉?
a b
c d
A. 8.
B. 20.
C. 22.
D. 24.
E. 25.
- 4 of 12 -
CS1231S
Part B: Multiple Response Questions [Total: 6×3 = 18 marks]
Each multiple response question (MRQ) is worth THREE marks and may have one answer or multiple
answers. Write out all correct answers. For example, if you think that A, B, C are the correct answers,
write A, B, C.
Only if you get all the answers correct will you be awarded three marks. No partial credit will be given
for partially correct answers.
- 5 of 12 -
CS1231S
14. Suppose 𝑓 and 𝑔 are functions, which of the following statements is/are true?
A. If 𝑓 and 𝑔 are injective, then 𝑔 ∘ 𝑓 is injective.
B. If 𝑓 and 𝑔 are surjective, then 𝑔 ∘ 𝑓 is surjective.
C. If 𝑓 and 𝑔 are bijective, then 𝑔 ∘ 𝑓 is bijective.
D. If 𝑔 ∘ 𝑓 is bijective, then 𝑓 and 𝑔 are bijective.
E. If 𝑔 ∘ 𝑓 is not bijective, then 𝑓 and 𝑔 are not bijective.
16. The following are the pre-order traversal and post-order traversal of a binary tree:
Pre-order: U C N A D O I T
Post-order: N C D I T O A U
Which of the following is/are possible in-order traversals of this tree?
A. CNUDAIO!T
B. CNUDAIOT!
C. NCUDAIOT!
D. NCUDAI!OT
E. None of the above.
- 6 of 12 -
CS1231S
Part C: There are 5 questions in this part [Total: 62 marks]
17. Prove by mathematical induction: 𝟕 | (𝟓𝟐𝒏+𝟏 + 𝟐𝟐𝒏+𝟏 ) for all 𝑛 ∈ ℕ. [Total: 5 marks]
- 7 of 12 -
CS1231S
19. Counting and Probability [Total: 20 marks]
Note that you need not show your working for parts (a) to (c).
(a) [Subtotal: 4 marks]
Three persons went to the famous Gluttons Gourmet Hawker Centre where four of the city’s best
hawker stalls are housed: DiDi Chicken Rice, Singing Char Kway Teow, Alamak Nasi Lemak and
Hurry Hurry Curry Fish Head. Assume that the three of them are indistinguishable. If each of them
is to order from one of these four stalls,
(i) in how many ways can they order their food? [1 mark]
(ii) in how many ways can they order their food from the same stall? [1 mark]
(ii) in how many ways can they order their food from two of the four stalls? [2 marks]
4m
- 8 of 12 -
CS1231S
20. Graphs and Trees [Total: 20 marks]
(a) Draw all non-isomorphic, connected simple graphs on four vertices. [3 marks]
(b) Prove or disprove the following statements: [8 marks]
(i) The graph 𝐾2,4 is a planar graph.
(ii) The graph 𝐾3,4 is a planar graph.
(iii) There exists a simple graph that is connected and planar with 5 vertices and 8 faces.
(iv) The graph 𝐾5 − {𝑒} where 𝑒 is any edge in the graph is 4-colourable.
(c) [Subtotal: 9 marks] You are given a set of 𝑛 tasks 𝑇 = {𝑇1 , 𝑇2 , 𝑇3 , … , 𝑇𝑛 } . Each task 𝑇𝑘 is
represented by the interval 𝐼𝑘 = [𝑠𝑘 , 𝑒𝑘 ) where 𝑠𝑘 is the start time and 𝑒𝑘 (where 𝑠𝑘 < 𝑒𝑘 ) is the
end time of the task, for 𝑘 = 1,2, … , 𝑛. An instance of this problem with 𝑛 = 10 is shown below.
Instance: 𝑛 = 10, and 𝑇 = {𝑇1 , 𝑇2 , … , 𝑇10 }, and
𝐼1 = [0, 3), 𝐼2 = [11, 19), 𝐼3 = [14, 20), 𝐼4 = [2, 5), 𝐼5 = [8, 12),
𝐼6 = [6, 10), 𝐼7 = [1, 5), 𝐼8 = [12, 16), 𝐼9 = [17, 19), 𝐼10 = [4, 9).
𝐼1 𝐼2
𝐼4 𝐼5 𝐼3
𝐼7 𝐼6 𝐼8
𝐼10 𝐼9
0 4 8 12 16 20
- 9 of 12 -
CS1231S
21. [Total: 7 marks]
(a) Define a partition of ℤ that divides ℤ into 1231 countably infinite subsets. You do not need to
explain your answer [2 marks]
(b) Define a bijection 𝑓: (0,1) → (0,1] so that you may conclude that (0,1) and (0,1] have the
same cardinality. Prove that your function 𝑓 is a bijection. [5 marks]
- 10 of 12 -
CS1231S
This page is intentionally left blank.
- 11 of 12 -
CS1231S
This page is intentionally left blank.
- 12 of 12 -