381hw8solns

# 381hw8solns - CS381 Homework#8 Solutions Question 1 Write a...

• Homework Help
• 501844684_ch
• 4

This preview shows pages 1–2. Sign up to view the full content.

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 | 0 X | Z 0 Z | S 1 0 X | X 11 X | X 0 | 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 00 greater than i+1 zeros in the second block GE 0 GE 0 | GE 0 | 1 L 0 LE 0

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.
• Fall '05
• HOPCROFT
• Formal language, adjacent blocks, ﬁrst block, cYd | epsilon

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern