Vous êtes sur la page 1sur 15

Question 1

a) i) ii)

Define the terms: Proposition Compound propositions

iii) Tautology iv) Contradiction v) Contingency [5 marks] Answers i) Proposition is a statement that is either true or false, but not both. ii) Compound propositions are new propositions result from combining existing propositions using logical operators such as and, or and others. iii) Tautology is a compound proposition that is always true. iv) Contradiction is a compound proposition that is always false. v) Contingency is a compound proposition that is neither a tautology nor a contradiction (consists both true and false value for different combination of propositions that are involved). [1 mark each, Total: 5 marks]

b)

Decide whether the following propositional formula is tautology, contingency or

contradiction using truth table. [ ( p q ) ( q p ) ] [5 marks] Answers: p 0 0 1 1 q 0 1 0 1 p q 0 0 0 1 (p q) 1 1 1 0 p 1 1 0 0 q p 0 1 0 0 (p q) (q p) 1 1 1 0 [(p q) (q p)] 0 0 0 1

It is a contingency. [Correct final answers (last column) = 4 marks] [Correct classification = 1 mark] [Total: 5 marks] Show that T [ ( p q ) p] and F [( p q ) ] are logically [4 marks] Answers: T [ ( p q ) p ] [ ( p q ) p ] [(p q) p] [(p q) p] [(p p) (q p)] [ T (q p)] (q p) (p q) F (p q) Identity Law Conversion Implication DeMorgan Distributive. Law Negation. Law Identity Law Commutative Law Identity Law [0.5 mark for each step, Total: 4 marks]

c)

equivalent without using truth table.

d)

Express the statement below using predicates and quantifiers


i)

All good answers are satisfactory.

ii) Some weak answers are unsatisfactory. iii) All weak answers are not good answers. P(x) = x is a good answer Q(x) = x is satisfactory R(x) = x is a weak answer [6 marks] Answers:
i) ii) iii)

(P(x) Q(x)) x

x (R(x)

(R (x) x

Q(x)) P(x)) [2 marks each, Total 6 marks]

Question 2 a) Define the terms below: i) Set ii) Partial order relation iii) Equivalence relation [3 marks] Answers: i) A set is defined to be an unordered collection of objects ii) A binary relation R on a set is said to be partial order if R is reflexive, antisymmetric and transitive. iii) A binary relation R on a set X is said to be equivalence relation if R is reflexive, symmetric and transitive. [1 mark each, Total: 3 marks]

b) Let A = {1, 2, 3}, B = {1, 4, 5} and C = {6}. List the elements of the following sets:
i)

(A B)

ii) (A

B) C

iii) A B

iv) B

A [4 marks] Answers:
i)

(A B)

C = {1, 2, 3, 4 ,5} {6} = { }

ii) (A

B) C = {1} {6} = {1, 6}

iii) A B = {2, 3} iv) B A = {4, 5} [1 mark each, total: 4 marks]

c) Give an example of relation R on set A = {1, 3, 5, 7} which fulfills the following conditions: i) R is reflexive ii) R is symmetric and antisymmetric iii) R is not symmetric and not antisymmetric iv) R is reflexive, symmetric, antisymmetric and transitive. [8 marks] Answers: [Note that there are many possible answers, below are just examples of them] i) R = {(1, 1), (3, 3), (5, 5), (7, 7)} ii) R = {(1, 1)} iii) R = {(1, 3), (3, 1), (5, 7)} iv) R = {(1, 1), (3, 3), (5, 5), (7, 7)} [2 marks each: Total: 8 marks] d) Consider the functions f(x) = x 1 and g(x) = x 2 + 2x +1. Find a formula for the composition function i) g o f ii) f o g [5 marks] Answers: 2 i) (g o f)(x) = g(f(x)) = g(x-1) = ( x 1) + 2(x-1) + 1 = ( x 2 - 2x +1) + (2x - 2)+1=
x2

ii)

(f o g)(x) = f(g(x)) = f( x 2 + 2x + 1) = ( x 2 +2x + 1) - 1 = x 2 + 2x [2.5 marks each, Total: 5 marks]

Question 3
a)

Write down an algorithm. The algorithm accepts 3 non-negative integers as the

inputs. First, the algorithm finds the maximum value of the 3 inputs. Next, it finds out the minimum value of the 3 inputs. Finally, it calculates the multiplication of the maximum and minimum input numbers. The calculated multiplication value will be the output of this algorithm. You can assume that the users of this algorithm will only input non-negative integers. [10 marks] Answers:
Algorithm 1: Finding the multiplication of maximum and minimum 3 non-negative integers. Input: Three non-negative integers a, b and c Output: x, the multiplication of maximum and minimum of a, b and c procedure mul_max_min(a, b, c) max := a If b > max then max := b if c > max then max := c min := a If b < min then min := b if c < min then min := c return(max*min) end mul_max_min

[Total: 10 marks]

b) Write another algorithm. This algorithm accepts 3 non-negative integers as the inputs. Similar to the algorithm in part a above, this algorithm calculates the multiplication value of the maximum and minimum of 3 non-negative input integers. However, this algorithm also checks whether the multiplied value is an even or odd number. If the result of multiplication is even, the word EVEN will be returned as the output. If the result is an odd number, the word ODD will be the output. You do not need to output the result of multiplication. This algorithm must call the algorithm in part a above to do the maximum and minimum integers identification and multiplication steps. You can assume that the users of this algorithm will only input non-negative integers. [5 marks] Answers:
Algorithm 2: Checking the result of multiplication between maximum and minimum 3 non-negative integers to see whether it is an even number or odd number. Input: Three non-negative integers a, b and c Output: x, the multiplication of maximum and minimum of a, b and c procedure check_even_odd(a, b, c) result = mul_max_min(a, b, c) if result%2==0 return (EVEN) else return (ODD) end check_even_odd

[Total: 5 marks]

c) Select a theta notation for the expression below: 12n3+24n2+2n [5 marks] Answers:
For n

1 12n3+24n2+2n 38n3 t(n) = O(n3) 12n3+24n2+2n 12n3 t(n) = (n3) Therefore, theta(n) = (n3)

[2 marks] [2 marks] [1 mark] [Total: 5 marks]

Question 4
a)

Using induction, prove that the equation below is true for every positive integer n:
1 2 + 2 3 + 3 4 + + n(n + 1) = n(n + 1)(n + 2) 3

[15 marks] Answers: Inductive Base When

n(n +1)( n + 2) 1(1 +1)(1 + 2) 6 = = =2. 3 3 3 n(n + 1)( n + 2) therefore, 1 2 + 2 3 + 3 4 + + n(n + 1) = is true when n=1. 3

n=1,

n(n+1)=1(1+1)=2,

and

[2 marks] Inductive Hypothesis Assuming 1 2 + 2 3 + 3 4 + + k (k + 1) =


k ( k + 1)( k + 2) is true. 3 n(n + 1)( n + 2) (i.e. assume 1 2 + 2 3 + 3 4 + + n(n + 1) = is true when 3

n=k.) [3 marks]

Proof under Hypothesis when n = k+1,

1 2 + 2 3 + 3 4 + + k (k + 1) + (k + 1)( k + 2) k (k + 1)( k + 2) = + (k + 1)( k + 2) 3 k = (k + 1)( k + 2)[ + 1] 3 (k + 1)( k + 2)( k + 3) = 3

therefore,
1 2 + 2 3 + 3 4 + + n(n + 1) =

n(n + 1)( n + 2) is true when n=k+1. 3

Conclusion
1 2 + 2 3 + 3 4 + + n(n + 1) =

n(n + 1)( n + 2) is true for every positive 3

integer n. [10 marks] [Total: 15 marks]


b)

Write down the first six terms (a1 until a6) of the sequence defined by a1 =1, a k+1 = 2(ak) + 2 for k 1 [5 marks]

Answers: The first six terms are a1 = 1 a2 = 4 a3 = 10 a4 = 22 a5 = 46 a6 = 94 2a1 = 2 2a2 = 8 2a3 = 20 2a4 = 44 2a5 = 92 [1 mark] [1 mark] [1 mark] [1 mark] [1 mark] [Total: 5 marks]

Question 5
a)

Suppose a book-shelf has 6 mathematics text books, 5 physics text books, 4

chemistry text books, and 3 computer science text books. Find the number of ways a student can choose:
i) ii)

One of the text books. One of each type of text books. [4 marks]

Answers: i) ii) 6 + 5 + 4 + 3 = 18 ways 6 5 4 3 = 360 ways [2 marks each, Total: 4 marks]


b)

Assume you have eight distinct compact disks (CDs). How many ways can the

CDs be divided among four of your best friends if each of them gets two CDs. [4 marks] Answers: Number of ways =
8! = 2520 ways 2!2!2!2!

[Total: 4 marks]

c)

How many binary bit strings of length ten contain exactly four 1s? [4 marks]

Answers: C(10, 4) =
1 ! 0 4!6!

= 210 bit strings [Total: 4 marks]

Question 6 a) Draw graphs having the given properties below. If no such graph exists, write

DOES NOT EXIST. i) one. ii) iii) iv) A graph having four vertices, each having degree of one. A complete and connected graph with 4 vertices. A connected but not complete graph with 4 vertices. [7 marks] Answers: i) Does not exist ii) [1 mark] [2 marks] A connected graph with three vertices, each having of degree

iii)

[2 marks]

iv)

[2 marks] [Total: 7 marks]

b) A vertex v in a connected graph is called an articulation vertex if removal of v and all edges incident on v results in a disconnected graph. i) Draw an example of a graph with five vertices that has exactly two articulation vertices. ii) Draw an example of a graph with six vertices that has no articulation vertex. [4 marks] Answers: i)

ii)

[2 marks each, Total: 4 marks]

c) Referring to the tree below, list the order in which the vertices are processed using: i) Preorder traversal ii) Inorder traversal iii) Postorder traversal

Answers: i) preorder: ii) inorder: iii) postorder: abejlfdgmqsniopv jelbfaqmsgndoipv jlefbqsmngovp ida [3 marks each, Total: 9 marks]

Question 7 a) What is the output of the following circuit? x y x y z

x
[5 marks] Answers: [(x + y) + (x yz)]+ x [1 mark for each correct gate output, Total: 5 marks]

Vous aimerez peut-être aussi