Universiti Teknologi Mara Final Examination: Confidential CS/APR 2008/ITC430/CSC510
Universiti Teknologi Mara Final Examination: Confidential CS/APR 2008/ITC430/CSC510
INSTRUCTIONS TO CANDIDATES
2. Answer ALL questions in the Answer Booklet. Start each answer on a new page.
3. Do not bring any material into the examination room unless permission is given by the
invigilator.
4. Please check to make sure that this examination pack consists of:
QUESTION 1
a) Write the logical expression P -> (-.Q A R) using only the connectives-. and A.
(4 marks)
b) Construct the truth table for the logical expression p v -,Q A -.R -> p. Determine if it is
a tautology, contradiction or contingent
(4 marks)
c) The symbols A, R and s stand for the propositions Mom is adventurous, Mom is rich, and
Mom visits many countries, respectively.
I. A -^ (R H> S)
II. A A R -^ S
(4 marks)
(4 marks)
QUESTION 2
a) With the aid of a truth table, determine whether the following argument is valid.
/ play golf or tennis. If it is not Sunday, I play golf and tennis. If it is
Saturday or Sunday then I don't play golf. Therefore I don't play golf.
Note: Use the symbols G, T, A and u to represent the propositions: I play golf, I play tennis,
It is Saturday, and It is Sunday, respectively.
(5 marks)
Every student in this class is a girl. Every girl in this class passed the final
examination. Norizan is a student in this class.
Explain why we can draw the conclusion: Norizan passed the final examination.
(4 marks)
c) Write the declarative proof (using inference rules) for the following argument.
Note: Use the symbols P, B and D to represent the propositions: Porsche enjoys good
prestige, Arun buys a Porsche, and Arun can drive, respectively.
(5 marks)
QUESTION 3
b) Using a Venn diagram, test the validity of the following argument. Explain your answer.
There are no athletes who are swimmers. Some swimmers are cyclists.
Therefore, some cyclists are not athletes.
(4 marks)
i. Prove that the expression is always true if the domain of discourse contains only a
single element.
(2 marks)
ii. Find a model for the expression over a domain of discourse with two elements,
{apple,orange}.
(4 marks)
QUESTION 4
a) Using set builder notation, describe the set of numbers { 2 , 3 , 4 , 5 } in T W O (2) different
ways.
(2 marks)
i. (A u B) n (~A u C) n (B u C) = (A u B) n (~A u c)
ii. (A - B) - C = (A - C) - (B - C)
(6 m a r k s )
c) P is a r e l a t i o n d e f i n e d o n t h e s e t { a , b , c , d } , s u c h t h a t p = { ( a , a ) , ( a , b ) ,
(a,c), (a,d), (b,a), (b,b), (b,c), (b,d), (c,b), (c,c), (d,b)}.
D e t e r m i n e w h e t h e r p is reflexive, s y m m e t r i c a n d / or t r a n s i t i v e . E x p l a i n y o u r a n s w e r .
(4 m a r k s )
d) L e t s e t s = { ( x , y ) | x e N , y e N , N < 1 0 } , w h e r e N is a n a t u r a l n u m b e r .
R e l a t i o n Q is d e f i n e d o n s s u c h t h a t Q = { ( w , x ) | x = y, w = z, ( y , z ) e Q},and
relation R is d e f i n e d o n s s u c h t h a t R = { ( x , y ) | x = y}.
QUESTION 5
a) What is the maximum and the minimum degree of vertices in the graph?
(2 marks)
f) Identify TWO (2) disjoint components comprising of ALL the vertices of the above
graph and only SEVEN (7) of the edges in the original graph.
(3 marks)
QUESTION 6
a) Compute the weakest precondition for each of the following program statements based on
their postconditions (the assertions in bold)
b . i f x < 0 t h e n x := x + 2 {x > 0}
(2 marks)
b) Study the program segment given below and answerthe questions that follow.
z := 0;
i := 0;
while (i <= n)
{
if (x < 0)
z := z + i - x;
else
z := z + i + x;
i := i + 1;
i. List a few sample data that you will use to test the program segment.
(3 marks)
ii. Formally proof that the program segment is correct using suitable assertions.
II. Next, find the loop invariant before verifying the loop statement.
(4 marks)
III. Finally, by taking into consideration the two assignment statements at the
beginning, compute the weakest precondition for the program segment.
(2 marks)
QUESTION 7
Study the grammar given below and answer the following questions.
G = { V , T , s , P} with
Vocabulary, v = { a , b , c, S, A , B , C } ,
Terminals, T = { a , b , c } ,
Starting symbol, S, and
Productions, P = {S -* C, C - aCAB, S -> A, BA -» AB, aA
a b , bA -» b b , bB -* b e , cB -. c c } .
{a n b k c n |n > 0, k > n}
(4 marks)