Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Regular expressions - odd amounts, as opposed to even

  • 30-10-2011 3:14pm
    #1
    Registered Users, Registered Users 2 Posts: 7,893 ✭✭✭


    Can someone answer this for me:

    Give a regular expression for "The set of all strings of 0's and 1's having an odd number of 0's".

    The input alphabet is obviously {0,1}. I understand the question, but I just don't know how to represent an odd amount of 0's in regular expression form. I could even draw a Finite State Machine to represent it!

    Any help appreciated.
    Thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 5,238 ✭✭✭humbert


    This looks like a sufficiently similar example. Although I only took a cursory glance at it.

    I think the approach would be to create an expression to find pairs of 0s that may or may not be consecutive, then find 0 to infinitely many of them, and finally check to make sure that sequence is followed by a 0.


    I'm sure there are other approaches.


Advertisement