CS1231 Mockmidterm Complete
CS1231 Mockmidterm Complete
(Semester 1: AY2018/19)
INSTRUCTIONS TO CANDIDATES
1. This assessment paper contains NINETEEN (19) questions in TWO (2) parts and
comprises ELEVEN (11) printed pages, including this page.
2. Answer ALL questions.
3. This is an OPEN BOOK, NON-GRADED, MOCK assessment.
4. You are allowed to use NUS APPROVED CALCULATORS.
5. You do not need to submit anything. You may keep this question paper.
CS1231 Discrete Structures Mock Midterm Test - Page 2 of 11 29/9/2018
Part I
(30 marks) Multiple choice questions.
Q1. (2 marks) On the fabled Island of Knights and Knaves, you meet three persons Aiken, Dueet, and Kenyu.
Knights always tell the truth, and knaves always lie. Given the following conversation, can you determine for
sure who are knights and who are knaves?
Aiken: Dueet is a knave.
Dueet: Between Kenyu and myself, exactly one is a knave.
Kenyu: Between Aiken and myself, exactly one is a knight.
A. Aiken is a knave, Dueet is a knight, Kenyu is a knave.
B. Aiken is a knight, Dueet is a knave, Kenyu is a knave.
C. Aiken is a knight, Dueet is a knave, Kenyu is a knight.
D. It is not possible to determine for sure.
E. None of the above.
Q2. (2 marks) Which of the following is the contrapositive of the statement:
“If a and b are both even, then a + b is even.”?
A. If a or b is odd, then a + b is even.
B. If a + b is odd, then a and b are both odd.
C. If a + b is odd, then a or b is odd.
D. If a + b is even, then a and b are both even.
E. None of the above.
The next two questions (Q7 to Q8) refer to the following scenario.
I.M. Smart tries to prove the statement:
For all integers n ≥ 6, it is always possible to divide a unit square into n smaller squares
(not necessarily of the same size).
Proof (by ?).
1. For all integers n ≥ 6, let P (n) be “There is a way to divide a unit square into n smaller
squares.”
2. Base cases: n = 6, 7.
2.1. By construction, we can divide the unit square into 6 and 7 squares:
Q7. (2 marks) Which of the following best fits into both occurrences of the ? above?
A. Assumption
B. Contradiction
C. Mathematical Induction
D. Strong Induction
E. Obviousness
Q8. (2 marks) Which statement below best describes Smart’s proof?
A. The proof is essentially correct.
B. The proof is invalid, because it uses pictures.
C. The proof is invalid, because the base cases are incomplete.
D. The proof is invalid, because it assumes on Line 3.1. that P (a) is true for all 6 ≤ a ≤ k, but we are
only allowed to assume that P (k) is true.
E. The proof is invalid, because it starts by considering a division of k − 2 squares and works up to a
division of k + 1 squares, but we cannot start with a unit square divided into a different number of
squares to prove a statement concerning a unit square divided into a larger number of squares.
Q9. (2 marks) Which of the following statements is true?
A. If p is a prime number, then p2 + 1 is never prime.
B. If n ∈ Z+ has sum of digits equal to 3, then n is never prime.
C. If an odd prime number p is converted from decimal to binary, and the resulting binary number is
read as a decimal number n, then n is always prime.
D. If p1 , p2 , p3 , . . . , pn are consecutive primes with n ∈ Z+ and p1 = 2, then (p1 · p2 · p3 · . . . · pn ) + 1 is
always prime.
E. None of the above.
Q10. (2 marks) Which of the following “extensions” of theorems or propositions discussed in this module so far is
actually true?
A. Theorem 4.3.2 (Well Ordering Principle) on the Rationals.
If a non-empty set S ⊆ Q has a lower bound, then S has a least element.
(Recall that Q is the set of all rational numbers.)
B. Theorem 4.4.1 (Quotient-Remainder Theorem) on Arbitrary Ranges.
Given any integers a, c and any positive integer b, there exist unique integers q and r such that
a = bq + r and c ≤ r < b + c.
C. Proposition 4.5.2 (Existence of gcd) on Zeros.
For any integers a, b, their gcd exists and is unique.
D. Converse of Theorem 4.5.3 (Bézout’s Identity).
Let a, b be integers, both nonzero, and d be an integer such that there exist integers x, y such that:
ax + by = d. Then gcd(a, b) = d.
E. None of the above.
CS1231 Discrete Structures Mock Midterm Test - Page 6 of 11 29/9/2018
Q15. (2 marks) Prof. Aaron was preparing a question for the midterm, when he accidentally spilled coffee onto
the test paper. Now the question looks like:
Find any x ∈ Z+ such that 30303x ≡ 123## (mod 77553).
A # represents a single digit which had coffee spilled on it.
Unfortunately, Prof. Aaron doesn’t remember the two digits which now cannot be read. However, he remembers
that the original question had exactly one solution x that satisfied x ≤ 1200.
With only the given information, which of the following can definitely be concluded about x?
A. 1 ≤ x ≤ 300.
B. 301 ≤ x ≤ 600.
C. 601 ≤ x ≤ 900.
D. 901 ≤ x ≤ 1200.
E. None of the above.
CS1231 Discrete Structures Mock Midterm Test - Page 8 of 11 29/9/2018
Part II
(20 marks) Structured questions.
Q16. (4 marks) Theorem 2.1.1 (Epp) is given below. Given any statement variables p, q, r, the following logical
equivalences hold.
In addition to the above, for simplicity, you may use the commutative form of the equivalences whenever
appropriate without citing the commutative law. For example, you may write ∼p ∨ p ≡ true instead of adding
an additional step such as ∼p ∨ p ≡ p ∨ ∼p ≡ true.
Using these rules, derive the simplest statement (in terms of number of instances of statement variables) that
is logically equivalent to
Apply only one law for each step of your simplification, and state the law used. Please leave a blank line
between steps. Do not use Truth Tables.
Your solution should not contain more than 10 steps, or full credit will not be given.
CS1231 Discrete Structures Mock Midterm Test - Page 9 of 11 29/9/2018
Q17. (4 marks) Consider the domain of discourse to be the non-empty set of all vegetables, and define the following
predicates:
Vitamin(x) means “x is a good source of vitamin A.”
SameFamily(x, y) means “x and y are in the same vegetable family.”
SameColor(x, y) means “x and y have the same color.”
For simplicity, assume that every vegetable is in exactly one family and has exactly one color.
Write the following English statements in terms of logical statements, using only the predicates defined above.
Do not define any new predicates. You may omit the domain of discourse from your statements.
Of course, you may use x = y and x 6= y to mean “x and y are the same vegetable” and “x and y are different
vegetables”, respectively.
(a) (1 mark) There is at least one vegetable which is a good source of vitamin A.
(b) (1 mark) All vegetables which are good sources of vitamin A are in the same family as Carrot.
(c) (2 marks) There are exactly two different vegetables in any vegetable family which are the same color.
CS1231 Discrete Structures Mock Midterm Test - Page 10 of 11 29/9/2018
Q18. (5 marks) A group of n ≥ 2 badminton players play a round-robin tournament (everyone plays against
everyone else exactly once). Every game ends in one player defeating the other, so ties are impossible.
Show that it is always possible to label all the players p1 , p2 , . . . , pn , such that ∀i ∈ Z+ , if i ≤ n − 1, pi defeated
pi+1 in the game played between them.
CS1231 Discrete Structures Mock Midterm Test - Page 11 of 11 29/9/2018
Q19. (7 marks) Call a positive integer awesome if it has exactly 3 positive divisors.
(a) (2 marks) Find the number of awesome positive integers less than 1231.
(b) (5 marks) Show that, ∀n ∈ Z+ , if the decimal representation of n ends in a 1 or a 7, then n cannot be
expressed as the sum of exactly two awesome positive integers.
For your convenience, you can use, without proving, the following facts:
I. The last digit in the decimal representation of a non-negative integer n is equal to n mod 10.
II. An integer is odd if and only if its decimal representation ends in an odd number (and likewise for
even).
III. ∀a, b ∈ Z and m ∈ Z+ , (a + b) mod m = [(a mod m) + (b mod m)] mod m.