cs1231s Exam21s1 Qns
cs1231s Exam21s1 Qns
INSTRUCTIONS
1. This assessment paper contains TWENTY FOUR (24) questions in THREE (3) parts and comprises
TEN (10) printed pages.
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.
1. Which of the following statements is true about the Monty Hall game that was shown in class?
A. There is a better chance of winning the car if the player sticks to her original guess.
B. There is a better chance of winning the car if the player changes her mind.
C. There is no difference whether the player sticks to her original guess or changes her mind.
D. None of (A), (B), (C) is true.
- 2 of 10 -
CS1231S
4. It is a fact that 𝑛 ⩽ 𝑛3 for all 𝑛 ∈ ℤ+ . From this fact, one can derive that
∀𝑛 ∈ ℤ+ ∃𝑚 ∈ ℤ+ (𝑚 − 1)3 < 𝑛 ⩽ 𝑚3 .
Which of the following enables one to do this easily?
A. The Pigeonhole Principle.
B. The Well-Ordering Principle.
C. The Inclusion–Exclusion Principle.
D. A diagonalization proof.
E. None of the above.
5. Let 𝑓: ℚ → ℚ satisfying 𝑓(𝑥) = 𝑥 2 for all 𝑥 ∈ ℚ. Which of the following statements is/are true?
(i) 𝑓(𝑋1 ∩ 𝑋2 ) = 𝑓(𝑋1 ) ∩ 𝑓(𝑋2 ) for all 𝑋1 , 𝑋2 ⊆ ℚ.
(ii) 𝑓 −1 (𝑌1 ∩ 𝑌2 ) = 𝑓 −1 (𝑌1 ) ∩ 𝑓 −1 (𝑌2 ) for all 𝑌1 , 𝑌2 ⊆ ℚ.
A. (i) and (ii) are both true.
B. (i) is true but (ii) is not.
C. (ii) is true but (i) is not.
D. (i) and (ii) are both not true.
7. Recall the definition of the graph of a function from Question 6. Here is an arrow diagram for the
graph of a function 𝑔: 𝐴 → 𝐴, viewed as a relation on 𝐴.
- 3 of 10 -
CS1231S
11. There are 2 enemies in a group of 15 people. In how many ways can this group be seated around
a circular conference table so that the enemies are never seated together? Note that the seats
are not numbered.
A. (13
2
)
B. (14
2
)
15!
C.
2
D. 14!
E. 12 × 13!
- 4 of 10 -
CS1231S
12. Which of the following statements is true about the complement graph of a bipartite graph?
A. The complement graph of a bipartite graph is also a bipartite graph.
B. The complement graph of a bipartite graph is a connected graph.
C. The complement graph of a bipartite graph contains two connected components.
D. The complement graph of a bipartite graph always contains a cycle.
E. None of the above.
14. Recall that {s, u}∗ denotes the set of all strings over {s, u}. Define 𝑓: {s, u}∗ → {s, u}∗ by setting
𝑓(𝜎) to be the result of removing all the occurrences of u in 𝜎, for all 𝜎 ∈ {s, u}∗ . Which of the
following statements is/are true?
A. The domain of 𝑓 is equal to the codomain of 𝑓.
B. The range of 𝑓 is equal to the codomain of 𝑓.
C. 𝑓 −1 exists as a function.
D. 𝑓 ∘ 𝑓 = 𝑓.
E. None of the above.
- 5 of 10 -
CS1231S
15. Define Bool = {𝐭𝐫𝐮𝐞, 𝐟𝐚𝐥𝐬𝐞} and 𝑓: Bool3 → Bool by setting, for all 𝑝, 𝑞, 𝑟 ∈ Bool,
𝑓(𝑝, 𝑞, 𝑟) = (𝑝 ∧ 𝑞) ∨ ~𝑟.
Which of the following statements is/are true?
A. The function 𝑓 is surjective.
B. The function 𝑓 is injective.
C. For all 𝑞, 𝑟 ∈ Bool, if 𝑓(𝐟𝐚𝐥𝐬𝐞, 𝑞, 𝑟) = 𝐭𝐫𝐮𝐞, then 𝑓(𝐭𝐫𝐮𝐞, 𝑞, 𝑟) = 𝐭𝐫𝐮𝐞.
D. For all 𝑝, 𝑞 ∈ Bool, if 𝑓(𝑝, 𝑞, 𝐟𝐚𝐥𝐬𝐞) = 𝐭𝐫𝐮𝐞, then 𝑓(𝑝, 𝑞, 𝐭𝐫𝐮𝐞) = 𝐭𝐫𝐮𝐞.
E. None of the above.
18. Given two events 𝐴 and 𝐵, such that 𝐴 ⊊ 𝐵 (i.e. 𝐴 is a proper subset of 𝐵); which of the following
statements must be true? (Note: 𝑃(𝐸) denotes the probability of an event 𝐸 occurring.)
A. 𝑃(𝐴) ≤ 𝑃(𝐵)
B. 𝑃(𝐴) ≥ 𝑃(𝐵)
C. 𝑃(𝐴̅) ≤ 𝑃(𝐵̅)
D. 𝑃(𝐴̅) ≥ 𝑃(𝐵̅)
E. None of the above.
- 6 of 10 -
CS1231S
21. Let 𝑓: 𝐴 → 𝐴 such that 𝑋 ⊆ 𝑓(𝑋) for all 𝑋 ⊆ 𝐴. Prove that 𝑓 = id𝐴 , the identity function on 𝐴.
[4 marks]
- 7 of 10 -
CS1231S
23. Counting and Probability [Total: 20 marks]
Note that you need not show your working for parts (a) to (d).
(a) You have $50,000 that you can use for investment. You are recommended 4 properties to invest
in. Each investment must be in multiples of $1000.
(i) How many different investment strategies are possible if you invest $50,000 in total?
[2 marks]
(ii) How many different investment strategies are possible if you need not invest the entire
amount of $50,000? [2 marks]
(b) A car manufacturer has 3 factories 𝐴, 𝐵 and 𝐶 producing 25%, 35% and 40% of all cars
respectively. The percentages of defective cars produced by factories 𝐴, 𝐵 and 𝐶 are 5%, 4% and
2% respectively.
(i) What is the probability that a car produced by the manufacturer is defective?
[2 marks]
(ii) You, as a customer, received a defective car. What is the probability that this car was
manufactured in factory 𝐵? [2 marks]
Write your answers in 3 significant figures.
(c) On returning home after today’s exam, you realized that you had lost your student card. The
probability that you left it in the exam hall is 60%, while the probability that you left it at the bus
stop is 20%. Having not found your card in the exam hall, what is the probability of finding it at
the bus stop? You may assume in your calculations that no one moved any lost properties at the
exam hall and at the bus stop. [3 marks]
(d) Each student of CS1231S submitted a 2-page report in Discrete Math. We have observed the
following pattern of errors. The probability of finding an error on the first page is 9%. If we find
errors on page 1, the probability of finding an error on page 2 jumps to 25%; but the probability
of finding an error on page 2 is 5% if page 1 has no errors. On average, how many pages of a report
will have errors?
Write your answer in 3 significant figures. [3 marks]
(e) Let 𝐴 be an event with probability 𝑝. We say that 𝐼 is an indicator variable for the event 𝐴 if
1 𝑖𝑓 𝐴 occurs
𝐼={
0 𝑖𝑓 𝐴̅ occurs
Find 𝐸[𝐼], the expected value of 𝐼. Show your working. [3 marks]
(f) Show that given any 5 distinct non-negative integers, two of them have a difference that is
divisible by 4. Explain your answer clearly. [3 marks]
- 8 of 10 -
CS1231S
24. Graphs and Trees [Total: 20 marks]
(a) Draw all non-isomorphic spanning trees of the following graph. [3 marks]
(b) Aiken defines his own versions of the binary tree traversals. In his versions, one visits the right
subtree before traversing the left subtree. Therefore, his pre-order traversal is root, right subtree,
left subtree, and his post-order traversal is right subtree, left subtree, root. A particular binary
tree has the following pre-order traversal and post-order traversal according to Aiken’s versions:
Pre-order: U C A N D O I T
Post-order: A D N C T I O U
Draw (clearly!) one example of such a binary tree. There is more than one solution. You need to
provide only one. No mark will be awarded if you draw more than one binary tree. [3 marks]
(d) Given the undirected graph below, how many walks of length three are there from vertex 𝑎 to
vertex 𝑑? You do not need to show your working. [3 marks]
𝑎 𝑏 𝑐 𝑑
- 9 of 10 -
CS1231S
24. (continue…)
(e) A set of vertices, 𝐷, in an undirected graph is said to be a dominating set if every vertex not in 𝐷
is adjacent to at least one vertex in 𝐷. A minimal dominating set is a dominating set such that
none of its proper subsets are dominating sets.
(i) Draw two non-isomorphic simple graphs with four vertices that have minimal dominating sets
of size one. Highlight the vertices in the minimal dominating set in your graphs. [2 marks]
(ii) Draw two non-isomorphic simple graphs with four vertices that have minimal dominating sets
of size three. Highlight the vertices in the minimal dominating set in your graphs. [2 marks]
(iii) The graph below shows different villages (vertices) and their connectivity in a certain district.
A telephone company wants to set up cellular towers such that all villages are covered by the
network. Each cellular tower can cover the village in which it is set up, together with all the
villages adjacent to it.
The cost of setting up a tower in the village a is 10 units, in the villages b, c, d, or e is 4 units,
in the village f is 7 units and in the villages g or h is 3 units. Describe one way in which the
company can set up its towers such that the total cost is minimized (that is, list out the villages
and the total cost). [2 marks]
- 10 of 10 -