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

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern