This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS381, Homework #8 Solutions Question 1 Write a CFG for (0 + 1) * { 101001000 ... 10 n 1  n ≥ 1 } First note that there are two main reasons that a string might not be in the language, L = { 101001000 ... 10 n 1  n ≥ 1 } . 1. It is not of the form 1(0 * 1) * , or does not have atleast two blocks. 2. It has two adjacent blocks of ones such that the number of ones in the second block is not one more than the number of ones in the first block. We can write CFGs for both of these. For the first: X → 1 X  X  Z → Z  S 1 → X  X 11 X  X  1  1 Z 1 Notice how we can fail to satisfy condition one: if we start or end with a zero, or if we have two adjacent ones without any seperating zeros we will fail. Finally, if we have zero or one block, we will not be caught by any of the previous expressions, but will still be invalid. Now for the second condition, considering seeing two adjacent blocks, such that there are i zeros in the first block: S 2 → X 1 G 1 X  X 1 L 1 X G → GE...
View
Full
Document
This homework help was uploaded on 09/28/2007 for the course COM S 381 taught by Professor Hopcroft during the Fall '05 term at Cornell.
 Fall '05
 HOPCROFT
 Formal language, adjacent blocks, ﬁrst block, cYd  epsilon

Click to edit the document details