lab_01_b_sol.pdf - Solutions for Discussion 01b Friday...

This preview shows page 1 - 2 out of 2 pages.

Solutions for Discussion 01b : Friday, January 18, 2019 Version: 1.01 CS/ECE 374: Algorithms & Models of Computation, Spring 2019 Give regular expressions for each of the following languages over the alphabet { 0 , 1 } . 1 All strings containing the substring 000 . Solution: ( 0 + 1 ) * 000 ( 0 + 1 ) * 2 All strings not containing the substring 000 . Solution: ( 1 + 01 + 001 ) * ( ε + 0 + 00 ) Solution: ( ε + 0 + 00 )( 1 ( ε + 0 + 00 )) * 3 All strings in which every run of 0 s has length at least 3 . Solution: ( 1 + 0000 * ) * Solution: ( ε + 1 )(( ε + 0000 * ) 1 ) * ( ε + 0000 * ) 4 All strings in which 1 does not appear after a substring 000 . Solution: ( 1 + 01 + 001 ) * 0 * 5 All strings containing at least three 0 s. Solution: ( 0 + 1 ) * 0 ( 0 + 1 ) * 0 ( 0 + 1 ) * 0 ( 0 + 1 ) * Solution: 1 * 01 * 01 * 0 ( 0 + 1 ) * or ( 0 + 1 ) * 01 * 01 * 01 * 6 Every string except 000 . ( Hint: Don’t try to be clever. ) Solution: Every string w 6 = 000 satisfies one of three conditions: Either w < 3 , or w = 3 and w 6 = 000 , or w > 3 . The first two cases include only a finite number of strings, so we just list them explicitly. The last case includes all strings of length at least 4 . ε + 0 + 1 + 00 + 01 + 10 + 11 + 001 + 010 + 011 + 100 + 101 + 110 + 111 + ( 1 + 0 )( 1 + 0 )( 1 + 0 )( 1 + 0 )( 1 + 0 ) * Solution: ε + 0 + 00 + ( 1 + 01 + 001 + 000 ( 1 + 0 ) ) ( 1 + 0 ) * 7 All strings w such that in every prefix of
Image of page 1

Subscribe to view the full document.

Image of page 2
  • Spring '07
  • whoever
  • Regular expression, Substring

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