advertisement

2012-08-30 Linköpings Tekniska Högskola Institutionen för Datavetenskap Gustav Nordh TDDD65 Problem Session 1 1. Which of the following statements are true, which are false? (Do not forget to justify your answer.) (a) If w is any string, then wR denotes the reverse of w. If L is any language, then LR denotes the language consisting of the reverses of all strings in L. If L is any language, then the language LLR must be equal to {wwR | w ∈ L}. (b) Every NFA can be converted to an equivalent one that has a single accepting state. (c) A DFA with n states that accepts an infinite language must accept at least two distinct strings w and x such that n < |w| ≤ 3n and n < |x| ≤ 3n. (d) There exists a regular language L over the alphabet {a, b} such that ai bi ∈ L for any natural number i. 2. Consider the following languages over the alphabet {0, 1}. (a) {w|w has at least three 0’s} (b) {w| in which each 1 is followed by at least one 0} (c) {w|w has even length and an odd number of 1’s} For each of them construct a DFA recognizing the language. 3. (a) Given a DFA M show how to construct a DFA that recognizes the complement of the language L(M ). Illustrate the construction on an example. (b) Show that this construction applied to an NFA N gives an NFA that does not necessarily recognize the complement of L(N ). Does this mean that the class of languages recognized by NFA’s is not closed under complement? 4. Let L1 = {x11y | x, y ∈ {0, 1}∗ and |x| > |y|}. Prove that L1 is not regular. 5. Consider the following NFA’s: (a) N1 = {{q0 , q1 }, {0, 1}, δ, q0 , {q1 }} where: δ(q0 , 0) = {q0 , q1 } δ(q0 , 1) = {q1 }, δ(q1 , 0) = ∅, δ(q1 , 1) = {q0 }, δ(q0 , ) = ∅, δ(q1 , ) = ∅. (b) N2 = {{q0 , q1 , q2 }, {0, 1}, δ, q0 , {q1 }} where: δ(q0 , 0) = {q2 } δ(q0 , 1) = ∅, δ(q0 , ) = {q1 }, δ(q1 , 0) = {q0 }, δ(q1 , 1) = ∅, δ(q1 , ) = ∅, δ(q2 , 0) = {q1 }, δ(q2 , 1) = {q2 , q1 }, δ(q2 , ) = ∅ 1 For each of the NFA’s construct an equivalent DFA using a standard construction. 6. For each of the languages described by the following regular expressions over Σ = {0, 1} give two strings that are members and two strings that are not members. (a) 0*1* (b) 0(10)*1 (c) 0*+1* (d) (000)* (e) (0+1)*0(0+1)*1(0+1)*0(0+1)* (f) ((11)*0)* 7. Describe each of the languages of Problem 2 by a regular expression. 8. For each of the languages L(N1 ) and L(N2 ) of Problem 5 construct a regular expression describing the respective language. 9. Convert the following regular expressions to NFA’s using the standard construction (Σ = {0, 1}). (a) 0(011)*+1 (b) 0*+(01)* 2