hwsoln04

Hwsoln04 - CS 341 Foundations of Computer Science II Prof Marvin Nakayama Homework 4 1 Use the procedure described in Lemma 1.55 to convert the

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: CS 341: Foundations of Computer Science II Prof. Marvin Nakayama Homework 4 1. Use the procedure described in Lemma 1.55 to convert the regular expression (((00) ∗ (11)) ∪ 01) ∗ into an NFA. Answer: 1 1 00 ε 11 1 ε 1 01 ε 1 (00) ∗ ε ε ε (00) ∗ (11) ε ε ε 1 ε 1 ε ε 1 (00) ∗ (11) ∪ 01 ε ε ε 1 ε 1 ε ε ε 1 ε ε ((00) ∗ (11) ∪ 01) ∗ ε ε ε 1 ε 1 ε ε ε 1 ε ε ε ε ε 2. Use the procedure described in Lemma 1.60 to convert the following DFA M to a regular expression. 1 2 3 a,b a b b a Answer: First convert DFA M into an equivalent GNFA G . 2 s t 1 2 3 ε a ∪ b a b b a ε ε ε Next, we eliminate the states of G (except for s and t ) one at a time. The order in which the states are eliminated does not matter. However, eliminating states in a different order from what is done below may result in a different (but also correct) regular expression. We first eliminate state 3 . To do this, we need to account for the paths 2 → 3 → 1 , which will create an arc from 2 to 1 labelled with ba ; 2 → 3 → 2 , which will create an arc from 2 to 2 labelled with bb ; and 2 → 3 → t , which will create an arc from 2 to t labelled with bε = b . We combine the previous arc from 2 to 2 labelled a with the new one labelled bb to get the new label a ∪ bb . s t 1 2 ε a ∪ b ba a ∪ bb ε ε b We next eliminate state 1 . To do this, we need to account for the following paths: s → 1 → 2 , which will create an arc from s to 2 labelled with ε ( a ∪ b ) = a ∪ b . s → 1 → t , which will create an arc from s to t labelled with εε = ε . 2 → 1 → 2 , which will create an arc from 2 to 2 labelled with ba ( a ∪ b ) . We combine this with the existing 2 to 2 arc to get the new label a ∪ bb ∪ ba ( a ∪ b ) . 2 → 1 → t , which will create an arc from 2 to t labelled with baε = ba . We combine this arc with the existing arc from 2 to t to get the new label b ∪ ba . 3 s t 2 a ∪ b ε a ∪ bb ∪ ba ( a ∪ b ) b ∪ ba Finally, we eliminate state 2 by adding an arc from s to t labelled ( a ∪ b )( a ∪ bb ∪ ba ( a ∪ b )) ∗ ( b ∪ ba ) . We then combine this with the existing s to t arc to get the new label ε ∪ ( a ∪ b )( a ∪ bb ∪ ba ( a ∪ b )) ∗ ( b ∪ ba ) ....
View Full Document

This note was uploaded on 01/22/2011 for the course CIS 341 taught by Professor Nakayama during the Fall '10 term at NJIT.

Page1 / 8

Hwsoln04 - CS 341 Foundations of Computer Science II Prof Marvin Nakayama Homework 4 1 Use the procedure described in Lemma 1.55 to convert the

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

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