CSC510 Feb 2022
CSC510 Feb 2022
INSTRUCTIONS TO CANDIDATES
5. Make sure your answer papers are readable. Write your answers clearly with your full name,
group and student ID.
6. Submit your answers via Google Classroom in pdf format. Please upload ONLY ONE (1) pdf
format file into Google Classroom
SELF DECLARATION
a) I know that plagiarism is wrong. Plagiarism is use another’s work and pretend that it is one’s own.
b) This assessment is my own work.
c) I have not involved, and will not allow anyone to copy my work with the intention of passing it off as
their own work.
d) I acknowledge that copying someone else’s work (or part of it) is wrong and declare that my
assessment is my own work.
Represent each of these statements below using the defined symbols and logical
connectives.
i. You are allowed to enter a supermarket only if your MySejahtera profile states
‘Low Risk’ or ‘Casual Contact No Symptom’.
ii. Neither MySejahtera profile states ‘Low Risk’ nor ‘Casual Contact No Symptom’
iii. You are allowed to enter a supermarket whenever the MySejahtera profile states
‘Low Risk’.
(6 marks)
ii. Zuraini will go camping unless she does not have transportation.
(4 marks)
(4 marks)
b) Convert the following expression into Conjunctive Normal Form with the aid of a truth table.
Z = (C ∨ ¬A) ∧ (¬B ∨ C) ∧ (A ∨ B)
(6 marks)
QUESTION 3
a) If Leila receives her allowances on Saturday, she will go out to have dinner with her friends.
Leila does not get her allowances as usual this week, then her sister Emily will cook her
dinner. However, Emily is neither a good cook nor has the time to cook for Leila. Therefore,
Leila will go out with her friends.
i. Based on the situation above, convert the arguments into propositional logic
statements. Let:
ii. From your answer above, use the Rule of Inference to check the conclusion’s
validity.
(6 marks)
a) Translate each of the following statements into logical expression using predicates,
quantifiers, and logical connectives.
b) Let S(x) be the statement “x sends volunteers to help flood victims in several states”, where
the domain for x consists of all universities in Malaysia. Express each of these
quantifications in English.
i. ∀xS(x)
(2 marks)
ii. ∃x¬S(x)
(2 marks)
QUESTION 5
i. Find 𝐴 ∪ 𝐵.
(2 marks)
ii. Find 𝐵 ∩ 𝐶.
(2 marks)
b) Given relation 𝑅 = {(𝑎, 𝑏), (𝑎, 𝑐), (𝑐, 𝑐), (𝑏, 𝑏), (𝑐, 𝑏), (𝑏, 𝑐)} on the set 𝐴 = {𝑎, 𝑏, 𝑐}. Show
whether 𝑅 is:
i. Reflexive
(2 marks)
ii. Symmetric
(2 marks)
iii. Transitive
(3 marks)
© Hak Cipta Universiti Teknologi MARA 4 CONFIDENTIAL
c) Show that 𝑓: 𝑅 → 𝑅 given by 𝑓(𝑥) = 5𝑥 3 + 1 is bijective.
(6 marks)
QUESTION 6
b) Design a deterministic finite-state automaton that accepts any strings over {1,0}, which
begins, and ends with 10, and any combination of numbers 1 or 0 in the middle. An
example of an accepted string is 101010, 10110010, 10111110, 10000010.
(8 marks)
a) Prove the assignment segment given below to its pre-condition and post-condition using
Hoare triple method.
{t >= 5}
void main()
{
int f,g,z;
z = 2 * t - 8;
g = 2 * z;
f = 2 * g - 5;
}
{f >= 3}
(4 marks)
b) Identify the weakest pre-condition for the following decision that can guarantee the post-
condition to be true.
{ ? }
integer m, n
if (m > n)
y = 8 / y + 1
else
y = 3 * y
{ y ≥ 9 }
(4 marks)
c)
i. Find the loop invariant for the program code below.
void main()
{
int y = 1, x = 0;
while (x < 4)
{
y = y * z;
x = x + 1;
}
}
(2 marks)
© Hak Cipta Universiti Teknologi MARA 6 CONFIDENTIAL
ii. Prove whether the loop invariant that you created in i. is valid or not using Hoare triple
method.
(2 marks)
(2 marks)