381-H3-1-2 - CS381 Homework#3 Solutions Questions 1&2 Give...

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

CS381, Homework #3 Solutions Questions 1&2 Give a regular expression for strings with an even number of zeros. There are quite a number of correct answers. The smallest one that I saw was: (01 * 0 + 1) * Any correct solution was accepted. Other popular answers were: 1. 1 * (01 * 01 * ) * 2. (1 * 01 * 0) * 1 * 3. 1 * (1 * 01 * 01 * ) * (Technically the leading 1 * in the parenthesis is unnec- essary. ) The two most common mistakes were: 1. Not accounting for strings with no zeros. Zero is an even number. 2. The following expression: 1 * (01 * 0) * 1 * . Initially this expression seems to work, but there is a large class of input that it does not accept. Consider any string of the form ...00100... This will not be accepted
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: by this expression, because there is no allotment made for the fact that a 1 can seperate a pair of zeros. Give a regular expression for strings with all zeros before any ones The correct answer to this question is: * 1 * There were very few people who had any trouble with this question. Some people assumed that you had to have a zero before any ones and provided 00 * 1 * . Technically, the question only specified that any zeros had to be before any ones. Also, a correct answer need to take account of the fact that the empty string is a member of this set. 1...
View Full Document

  • Fall '05
  • HOPCROFT
  • Regular expression, Zero

{[ 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