{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw5 - deterministic machine should be the sets of states of...

This preview shows page 1. Sign up to view the full content.

CSC236H: Introduction to the Theory of Computation Homework 5 Due on Tuesday April 6, 2010 (in review session, see announcements) 1. Give a context-free grammar for each of the following languages. (a) L 1 = { 0 n 1 m 0 m 1 n | n,m 0 } . (b) L 2 = { a n b m c k | n,m,k 0 and n = m + k } . (c) L 3 = { a n b m c k | n,m,k 0 and n = 2 m + 3 k } . (d) L 4 = { a n b m | 0 n m 2 n } . 2. In a string w ∈ { 0 , 1 } * , deﬁne a block to be a maximal length consecutive sequence of 0s or 1s. For example, in the string 0111000011001 there are six blocks, three blocks of 0s of lengths 1, 4, and 2, and three blocks of 1s of lengths 3, 2, and 1. Let L be the language consisting of all strings that have (somewhere) two blocks of zeros of the same length. So, for example, 011001110 L but 000110011 6∈ L . (a) Prove that L is not regular. (b) Show that L is context-free by giving a grammar for L . (c) Prove that your grammar of part (b) is correct. 3. Consider the NFA deﬁned by the transition table below, with p the initial state and r the only accepting state. state input 0 input 1 p { p,s } { q } q { r,s } { q } r { r } { s } s {} { q } Construct a DFA that accepts the same language using the technique discussed in class. The states of your
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: deterministic machine should be the sets of states of the nondeterministic machine. 4. Give NFAs with the speciﬁed number of states recognizing each of the following languages. (a) The language { w | w ends with 00 } with three states. (b) The language { w | w contains the substring 0101, i.e., w = x 0101 y for some x and y } with ﬁve states. (c) The language { w | w contains an even number of 0s, or exactly two 1s } with six states. (d) The language 0 * 1 * * 0 with three states. 5. Give regular expressions for: (a) All binary strings with exactly two 1’s. (b) All binary strings with a double symbol (contains 00 or 11) somewhere. (c) All binary strings that contain both 00 and 11 as substrings. (d) All binary strings without a double symbol anywhere. 1...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online