compe330_hw2_sols

# compe330_hw2_sols - COMP 330 Autumn 2006 Assignment 2...

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

COMP 330 Autumn 2006 Assignment 2 Prakash Panangaden Solutions Question 1 [20 points] Give regular expressions for the following languages over { a, b } : 1. { w | w begins and ends with an a } . Solution: a + a ( a + b ) * a . 2. { w | every odd position is a b } . Solution: ( b ( a + b )) * b * . Note that “every odd position is a b does not imply that every even position is an a . 3. { w | w contains at least two a s and at most one b } . Solution: aaa * + aaa * b + aa * baa * + baaa * . 4. All strings except the empty string. Solution: a ( a + b ) * + b ( a + b ) * . Question 2 [20 points] Write Fnite automata that accept the following regular expressions: 1. ² + a ( a + b ) * + ( a + b ) * aa ( a + b ) * Solution a b a a,b b a b b a a,b 1

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

View Full Document
2. [ ba + ( a + bb ) a * b ] * Solution b a b b a a Question 3 [20 points] Give a DFA that recognizes valid decimal numbers. These are numbers that have a decimal point and an optional positive or negative sign in front. There may be digits
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 12/01/2009 for the course COMP COMP 330 taught by Professor Panangaden during the Spring '04 term at McGill.

### Page1 / 3

compe330_hw2_sols - COMP 330 Autumn 2006 Assignment 2...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online