This preview shows pages 1–4. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 341: Foundations of Computer Science II Prof. Marvin Nakayama Homework 3 Solutions 1. Give NFAs with the specified number of states recognizing each of the following lan guages. In all cases, the alphabet is = { , 1 } . (a) The language { w  w ends with 00 } with three states. 1 2 3 , 1 (b) The language { w  w contains the substring 0101 , i.e., w = x 0101 y for some x,y } with five states. 1 2 3 4 5 , 1 1 1 , 1 (c) The language { w  w contains at least two s, or exactly two 1 s } with six states. 1 2 5 3 4 6 , 1 1 , 1 1 1 (d) The language { } with one state. 1 1 (e) The language 1 with three states. 1 2 3 1 2. (a) Show by giving an example that, if M is an NFA that recognizes language C , swapping the accept and nonaccept states in M doesnt necessarily yield a new NFA that recognizes C . Answer: The NFA M below recognizes the language C = { w  w ends with 00 } , where = { , 1 } . 1 2 3 , 1 Swapping the accept and nonaccept states of M gives the following NFA M : 1 2 3 , 1 Note that M accepts the string 100 negationslash C = { w  w does not end with 00 } , so M does not recognize the language C . (b) Is the class of languages recognized by NFAs closed under complement? Explain your answer. Answer: The class of languages recognized by NFAs is closed under complement, which we can prove as follows. Suppose that C is a language recognized by some NFA M , i.e., C = L ( M ) . Since every NFA has an equivalent DFA (Theorem 1.19), there is a DFA D such that L ( D ) = L ( M ) = C . By problem 3 on Homework 2, we then know there is another DFA D that recognizes the language L ( D ) . Since 2 every DFA is also an NFA, this then shows that there is an NFA, in particular D , that recognizes the language C = L ( D ) . Thus, the class of languages recognized by NFAs is closed under complement. 3. Use the construction given in Theorem 1.39 to convert the following NFA N into an equivalent DFA. 1 2 3 a a a,b b Answer: Let NFA N = ( Q, ,, 1 ,F ) , where Q = { 1 , 2 , 3) , = { a,b } , 1 is the start state, F = { 2 } , and the transition function as in the diagram of N ....
View Full
Document
 Spring '12
 JOHN
 Computer Science

Click to edit the document details