Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6621847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:19:28+00:00 2026-05-25T21:19:28+00:00

Letting {a b} be the alphabet set, write a regular expression for: 1) The

  • 0

Letting {a b} be the alphabet set, write a regular expression for:

1) The language of all those words in which the number of a’s and the number of b’s are both odd;

2) The language of all those words whose length is odd and which contain the substring ab.

Also, if possible, please help me find two different expressions for each so as to help strengthen my understanding of how to go about solving such problems.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:19:29+00:00Added an answer on May 25, 2026 at 9:19 pm

    For the first one, there’s an easy 4-state DFA you can construct to recognize the language. Then, you can use the algorithm recoverable from Kleene’s theorem (the part where he says all languages recognized by a FA are generated by a RE) to get an RE that works… or just reason it out from the diagram.

    For the second one, you know that (ab) is part of the RE; now, you need to think of all the unique ways you could add an odd number of characters to this (front or back), and connect all those possibilities with + for an easy, correct RE.

    I don’t think anybody particularly likes the idea of just giving you the answer.

    EDIT:

    So now that some time has passed, I’ll work through the answer to the first one to show interested readers how it can be done.

    Our first FA is this:

       Q s f(Q, s)
      -- - -------
      EE a     OE
      EE b     EO
      OE a     EE
      OE b     OO
      EO a     OO
      EO b     EE
      OO a     EO
      OO b     OE
    

    We will remove states from this and replace s with a regular expression to cover that state. We start with an easy one… let’s get rid of OE. Here’s the table for that…

       Q                  regex f(Q, s)
      -- ---------------------- -------
      EE                     aa      EE
      EE                     ab      OO
      EE                      b      EO
      EO                      a      OO
      EO                      b      EE
      OO                      a      EO
      OO                     ba      EE
      OO                     bb      OO
    

    Convince yourself this is correct before continuing. Next, we get rid of EO:

       Q                  regex f(Q, s)
      -- ---------------------- -------
      EE                  aa+bb      EE
      EE                  ab+ba      OO
      OO                  ab+ba      EE
      OO                  aa+bb      OO
    

    To make the next step simpler, we introduce a new start set X and a new accepting state Y; OO is no longer accepting. We eliminate the need for OO:

       Q                        regex f(Q, s)
      -- ---------------------------- -------
       X                        empty      EE
      EE aa+bb+(ab+ba)(aa+bb)*(ab+ba)      EE
      EE              (ab+ba)(aa+bb)*       Y
    

    Therefore, the final regex is

      (aa+bb+(ab+ba)(aa+bb)*(ab+ba))*(ab+ba)(aa+bb)*
    

    We can begin trying to list the smallest strings this generates, just as a basic sanity check: {ab, ba, aaab, aaba, bbab, bbba, abaa, abbb, baaa, babb, …} Looks good to me!

    The rules for reducing at each step can be formalized, or you can just apply careful reasoning to ensure that you’re getting the right thing. Check a proof of Kleene’s theorem for a careful analysis. Also, Martin’s Introduction to Formal Languages or something has good examples of using this algorithm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm letting users choose their preferred language setting for number, currency and date formats.
I have an issue with letting my secret API key be all over the
Is it possible to redirect all requests to x.domain.com/.* to y.domain.com/.* WITHOUT letting this
I'm letting users enter GPS values through a form, they all have the same
I'm planning on letting a user draw the shape of a number (1 to
I am wondering why my UINavigationController is not letting me set a title. It
We're letting users search a database from a single text input and I'm having
I am a big fan of letting the compiler do as much work for
I'm looking for Javascript code for letting the user draw a line (on an
I'd like to have an 'UnassignedDepartment' object instead of letting employees have a null

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.