381-H3-1-2 - by this expression, because there is no...

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

View Full Document Right Arrow Icon
CS381, Homework #3 Solutions 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
Background 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 specied 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

Ask a homework question - tutors are online