1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Regex for given languages with constraints

  1. Sep 21, 2014 #1
    1. The problem statement, all variables and given/known data

    Make a regex for the following languages on Σ = {a, b}:
    (a) {w | each 'a' in w is immediately preceded and followed by 'b'}.
    (b) {w | w has both 'ab' and 'ba' as sub-strings }
    (c) {w ∈ {a, b} |(na(w) − nb(w)) mod 3 =/= 0}.

    For c, the number of a's minus the number of b's, modulo 3, must not be 0.

    3. The attempt at a solution

    a) (b*ba)(b*ba)*bb*+b*
    b) (a+b)*((bab)+(aba))(a+b)*
    c) (a*b*a)*+(a*b*aa)*+(a*b*b)*+(a*b*bb)*

    C seems wrong and maybe i messed up B.. Any thoughts?
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Discussions: Regex for given languages with constraints
  1. C language (Replies: 5)

  2. NFA for this language (Replies: 0)