40+PS5+Solutions

40+PS5+Solutions - Handout #40 May 6, 2011 CS103 Robert...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Handout #40 CS103 May 6, 2011 Robert Plummer Problem Set #5 Solutions 1. Consider that following state diagram: For each of the following, give the sequence of states that the machine goes through for each of the following inputs, and indicate which are accepted: (i) abaabbba The states are 0, 3, 1, 3, 4, 5, 5, 5, 5 Accepted (ii) babababbbbb The states are 0, 1, 3, 1, 3, 1, 3, 1, 2, 2, 2, 2 Not accepted (iii) aaabbbaaa The states are 0, 3, 4, 4, 5, 5, 5, 5, 5, 5 Accepted q 0 q 1 q 3 q 2 q 4 q 5 b b a a a a b b b a, b
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 2. Draw the state diagram of a DFA that accepts all strings from the following language: L = { w | w {0, 1}* and w contains neither 00 nor 11 as a substring}. [Be sure to indicate the starting state and which states are accepting.] 3. (a) Draw the state diagram for a DFA that accepts all strings over the alphabet {a, b} that contain an even number of a's or exactly two b's. (b) Characterize in English each of the states of your automaton by stating the kinds of strings that would cause the machine to end in that state. For example, one of your answers might be "State __: the machine ends here if the input string has an even number of a's." (a) (b) q0 - Even number of a's, no b's q1 - Odd number of a's, no b's q2 - Even number of a's, one b q3 - Odd number of a's, one b q4 - Even number of a's, exactly two b's q5 - Odd number of a's, exactly two b's q6 - Even number of a's, more than two b's q7 - Odd number of a's, more than two b's q 0 q 1 0 1 q 2 0 1 q 2 0, 1 0 1
Background image of page 2
3 4. Prove that all finite languages are regular. Proof. A finite language contains a finite number of strings. Let L be a finite language, and consider each string in L to be a regular expression. The union of those expressions is a regular expression describing L. Every regular expression corresponds to a regular language by Kleene's Theorem.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/01/2011 for the course EE 103 taught by Professor Plummer during the Spring '11 term at Stanford.

Page1 / 6

40+PS5+Solutions - Handout #40 May 6, 2011 CS103 Robert...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online