Vous êtes sur la page 1sur 6
UNIVERSITY EXAMINATIONS. UNIVERSITEITSEKSAMENS UNISA lcs COS2601 OctoberNNovember 2016 THEORETICAL COMPUTER SCIENCE II Duration 2 Hours 100 Marks EXAMINERS FIRST MR CL PILKINGTON SECOND OR WIC VAN STADEN Ctosed book examination This examination question paper remains the property of the University of South Africa and may not be removed from the examination venue ‘This examination question paper consists of 6 pages Instructions 1 Answer all questions 2. Allirough work must be done in your answer book 3 The mark for each question 1s given in brackets next to the question 4 Unless otherwise specified, all languages in the questions are defined over the alphabet ¥ = {a b} ALL THE BEST! (TURN OVER] 2 cos2601 # October/November 2016 SECTION 1 REGULAR EXPRESSIONS AND LANGUAGES [20 marks] (b) @) (e) @ (a) (b) (0) (d) 0) Consider the language S* where S = {a ab bba bab} \s abbabbba a word in S*? Justify your answer by indicating how the word can be made up of concatenations of words in S, or why it cannot be done 2) Provide a set S and a set T such that S ¢ T, T ¢ S, but St=T* (2) Provide a set S such that S* = S* (1) Provide a set S such that S*= {} (1) Let S = {a bb bab} Provide all the words in S* with exactly four letters @) If = (a bc} and the language L = 5*, how many 4-letter words are there in L HINT Do not try to wnte them all out, calculate the answer O) Give a regular expression which generates the language of all words that begin and end with double letters (that 1s, aa or 6b) (Words such as abab or aaba or ababbaaa etc are not in the language, but words such as aabb or bbaaa etc are inthe language) (3) Consider the language L defined by the regular expression (bb)*(abba* + bbb)* Determine whether the following two words are in the language L or not Explain fully why you say so by showing how the word is, or 1s not, generated by the regular expression (). bbabbabba (2) (0) bbbbabbaabbbb (2) Consider the regular expression (ba + bb*a)* Does the regular expression generate all the words that do not contain the aa-substring in them? Justify your answer (2) The regular expression a*b*(a + b)a’b* ts not equivalent to (a + b)* Give one word that cannot be generated by both regular expressions (1) [TURN OVER} 3 cos2601 a October/November 2016 SECTION 2 RECURSIVE AND INDUCTIVE PRINCIPLES [20 marks) A recursive definition for the language EvenNotAB defined over the alphabet = {a b} should be compiled EvenNotAB consists of all words that are of even length, and that do not contain the ab substring Provide (@) an appropnate unwersal set, (1) (b) the generator(s) of EvenNotAB, a) (c) an appropnate function on the universal set, and then 1) (¢) use these concepts to write down a recursive definition for the language EvenNotaB. 7) fa) (b) () Provide a recursive definition for the set P of all integers greater than 3, (1) formulate the associated induction principle, and then @) apply this induction pnnciple to prove that n! > 2" for all n > 3 @) Remember that nt = (1)(2)(3)(4) . (n-1)(n) SECTION 3 REGULAR LANGUAGE ACCEPTORS [20 marks] Consider the language L, defined over the alphabet > = {a b}, consisting of all words that fa) (b) () start with an a-substning, and do not end on an ab-substnng Wnte down the shortest word that should be accepted by the FA (1) Wnte down a word that should not be accepted by the FA (1) Build an FA (finite automaton) that accepts L_Use your answers in (a) and (b) above to check your solution (8) [TURN OVER]

Vous aimerez peut-être aussi