UNIVERSITY OF SWAZILAND Faculty of Science Department of Computer Science Supplementary Examination - July 2013 Title of Paper: LOGIC FOR COMPUTER SCIENCE Course Number: CS235 Time Allowed: 3 hours Total Marks:l00 Instructions to candidates: This question paper consists ofsix (6) questions. Answer any FOUR (4) questions. Marks are indicated in square brackets. All questions carry equal marks. SPECIAL REQUIREMENTS: NO CALCULATORS ALLOWED FOR THIS EXAM THIS EXAMINATION PAPER SHOULD NOT BE OPENED UNTIL PERMISSION HAS BEEN GRANTED BY THE INVIGILATOR Page 1 ofs
QUESTIONl a) i) State 2 limitations oftruth tables. [2] ii) List 3 areas ofapplication oflogic in Computer Science. [3] b) Explain the difference between the following terms: i) Propositional logic syntax and propositional logic semantics. [2] ii) Atomic and Compound propositions [2] c) Suppose you encounter three members A, B and C of the island of TuFa (remember that the Tu's always tell the truth, the Fa's always lie). They each give you a statement which we will assume you have translated into propositional logic as follows, where A denotes the statement: Member A says:... (A V B V C) A (... A V... B V... C) Use the truth table to determine whether A's proposition is a Tautology, a Contradiction or Contingent. To which tribe does this member belong? [10] d) What is the value of x after each of the following statements are encountered in a computer program, ifx 1 before the statement is reached. Explain fully. i) if 2 + 3 = 6 AND 3 + 4 == 7 then x:== x + 1 [3] ii) if 2 + 3 == 6 XOR 3 + 4 == 7 then x:= x + 1 [3] QUESTION 2 a) i) Using truth tables, show that (AVB)-+ C is equivalent to (A-+C)A (B-+C) [4] ii) From the truth table in i) above, determine the Conjunctive Normal Form (CNF) and the Disjunctive Normal Form (DNF) of(a V B)-+ C [6] b) Three boys, Melusi, Brian and Nkosi are caught, suspected ofbreaking the glass in a lab. - Melusi says: "Brian did it; Nkosi is innocent", - Brian says: "IfMelusi is guilty then so is Nkosi". Nkosi says: "I didn't do it; one ofthe others did", i) Are the statements consistent? [6] ii) Assuming that everyone is innocent, who told lies? [3] iii) Assuming that everyone's statement is true, who is innocent and who is guilty? [2] c) Using laws of equivalence, show that i) [.., P A (p V q)] -+ q is a tautology. [4] Page 20f5
QUESTION 3 a) A traditional children's riddle concerns a Farmer who is traveling with a sack of Rye, a Goose, and a mischievous Dog. The farmer comes to a river that he must cross from east to west. A boat is available, but it only has room for the farmer and one of his possessions. If the farmer is not present, the goose will eat the rye or the dog will eat the goose. We wish to design a circuit to emulate the conditions ofthis riddle. A separate switch is provided for the farmer, the rye, the goose and the dog. Each switch has two states, depending on whether the corresponding object is on the east bank or the west bank ofthe river. The rules of play stipulate that no more than two switches be moved at a time and that the farmer must move (to row the boat) each time switch are moved. The switch for the farmer provides logic signal F, which is high ifthe farmer is on the east bank and low if he is on the west bank. Similarly, logic signals (G for the goose, D for the dog and R for the rye) are high if the corresponding object is in the east bank and low if it is on the west bank. Construct the truth table for this riddle and hence find the Boolean logic expression based on the sum of products approach for a logic signal A (Alarm) that is high any time the rye or the goose are in danger of being eaten. Repeat for the product of sums approach. [12] b) Convert the following into SOP form and minimize using the Karnaugh map method. F= AB+ABC+BCD [8] c) Interpret the circuit diagram in1ik.j. and then complete the truth table that follows.[5] Ao---~ C BO-------- -------------~ Q Fig 1:, ~<ll:);:'<'l:, la<....{;!. <. ;c:;{b'.,'" ;<,jy... "'"j'" IQc.T,Y : \.." 0 0 1 0 0 1 1 1 1 0 0 0 1 1 0 0 C." Page 3 ofs
QUESTION 4 a) The state of a CPU register is 0100110101, what is its content if it represents: i. Digits in BCD ii. Digits in two's compliment [6] b) Simplify the following expression using Boolean theorems. (A+B)+C [4] c) i) Briefly explain the difference between the Karnaugh map method and the Quine- McCluskey method. [3] ii) Minimize the function F(A, B, C, D) =I (0,3,5,7,11,13,15) using the Quine- McCluskey method. [12] QUESTION 5 a) Convert i) 1023.062510 to binary [4] ii) 769 to BCD [2] iii) 93 to Hexadecimal [3] iv) 11 011.1011 to decimal [3] Show all the working. b) Find the 2's compliment representation of-73. Explain why the 2's complement arithmetic is commonly used as compared to other methods. [6] c) With the aid of well-labeled circuit diagrams, distinguish between the Half adder and full adder circuits in the way they operate. [7] Page 4 of5
QUESTION 6 a) Given A, A only ifb, B only ifc. Therefore C. Prove that the conclusion, C, is valid [3] b) With the aid ofclear diagrams explain the operations ofthe following: i) 4 to 1 - line Multiplexer [5] ii) 3 to 8 - line Decoder [5] c) "Ifthe program is running then there is at least 250K ofram." Which ofthe following are equivalent to this statement? [5] i) Ifthere is at least 250K ofram then the program is running. ii) Ifthere is less than 250K ofram then the program is not running. iii) The program will run only ifthere is at least 250K ofram. iv) Ifthe program is not running then there is less than 250K ofram. v) A necessary condition for the program to run is that there are at least 250K of RAM. d) Flip flops can be implemented using R-S, D-type or J-K. Explain the behavior ofj-k flip-flop. What additional logic is required to convert a J-K flip-flop into a D-type flip flop? [7] «<End of Question Paper»> PageS ofs