example1 - Describing Regular Expressions CMSC 330...

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

View Full Document Right Arrow Icon
1 CMSC 330: Organization of Programming Languages Examples of REs & Finite Automata CMSC 330 2 Describing Regular Expressions a) 0(0|1)*0 All strings beginning and ending in 0 b) (( |0)1*)* All strings c) (0|1)*0(0|1)(0|1) All strings with 0 as third digit from right CMSC 330 3 Creating Regular Expressions For all strings of 0’s and 1’s that… a) Begin in 1 1(0|1)* b) End in 1 (0|1)*1 c) Contains 00 (0|1)*00(0|1)* d) Do not contain 00 (01|1)*( |0) CMSC 330 4 Creating NFA For all strings of 0’s and 1’s that… a) Begin in 1 b) End in 1 c) Contains 00 d) Do not contain 00 1 0,1 1 0 0 0,1 0 0,1 0,1 1 0 Based on regular expression CMSC 330 5 Creating DFA For all strings of 0’s and 1’s that… a) Begin in 1 b) End in 1 c) Contains 00 d) Do not contain 00 1 0 0,1 0 1 1 0 0 1 1 0,1 0 0 1 1 0,1 Swap final / non-final states! CMSC 330 6 a) Construct NFA b) Accept ababbab 7,5,1,2,6,8,7,5,3,4,6,8,7,5,1,2,6,8,7,5,3,4,6,8,7,5,3,4,6, 8,7,5,1,2,6,8,7,5,3,4,6,8 accept For RE (a | b )* a 3 4 b 1 2 5 6 7 8
Image of page 1

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

View Full Document Right Arrow Icon
2 CMSC 330 7 For RE (a | b )* c) Reduce NFA to DFA Start = ε -closure(7) = {7,5,1,3,8} R = {{7,5,1,3,8}} r R = {7,5,1,3,8 } // mark DFA state move ({7,5,1,3,8}, a) = {2} e = ε -closure({2}) = {2,6,8,7,5,1,3}
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

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