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 6755097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:21:35+00:00 2026-05-26T13:21:35+00:00

This is an exercise of compiler. We are asked if it’s possible to match

  • 0

This is an exercise of compiler. We are asked if it’s possible to match the following patterns with regular expression or context free grammar:

  1. n ‘a’ followed by n ‘b’, like ‘aabb’
  2. palindrome, like ‘abbccbba’
  3. n ‘a’, then n ‘b’, then n ‘c’, like ‘aabbcc’

Note that n could be any positive integer. (Otherwise it’s too simple)

Only 3 character ‘abc’ could appear in the text to parse.

I’m confused because as far as I can see, non of these patterns can be described by regular expression and context free grammar.

  • 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-26T13:21:36+00:00Added an answer on May 26, 2026 at 1:21 pm

    The critical question is: how much and what kind of memory do you need?

    In the case of problem 1, you need to somehow keep track of the number of a terminals as you are parsing the b terminals. Since you know you need one for one, a stack is clearly sufficient (you can put the a on the stack and pop one off with every b). Since a pushdown automaton is equivalent to a CFG in expressive power, you can create a CFG for problem 1.

    In the case of problem 2, the technique that a PDA uses in problem 1 should be suggestive of a technique you could use for problem 2. PDAs can build a stack of the first half of the input, then pop it off as its reverse comes in.

    In the case of problem 3, if you use the stack technique for counting the number of a terminals and b terminals, that’s all well and good, but what happened to your stack memory? Was it sufficient? No, you would have needed to store the number of as somewhere else, so a CFG cannot express this grammar.

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

Sidebar

Related Questions

This is a learning exercise in expression trees. I have this working code: class
For this exercise I'm making I want a decimal < 4096 to be written
Let's say I have a large query (for the purposes of this exercise say
I am doing this small exercise. declare @No decimal(38,5); set @No=12345678910111213.14151; select @No*1000/1000,@No/1000*1000,@No; Results
The exercise in this tutorial says: Generate a 10 x 3 array of random
This is an academic exercise, I'm new to Reactive Extensions and trying to get
This is a programming exercise from Chapter 6 of The Art and Science of
This is a thought exercise, not a particular problem, but I'd like to hear
This is my first effort on solving the exercise. I gotta say, I'm kind
As an exercise for my Java course in Uni this morning, I had to

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.