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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:40:32+00:00 2026-05-18T19:40:32+00:00

I am studying for my finals & I was reading context free grammars article

  • 0

I am studying for my finals & I was reading context free grammars article from wikipedia and came across following example.

S → SS- (1st production rule)

S → (S) - (2nd production rule)

S → () - (3rd production rule)

I am well aware of left and right derivation. When I tried to solve this problem I start with start symbol

S-> SS -> (S)S-> ()S-> ()(S) -> ()() 

but when I looked the answer, it was like this

S → SS → SSS → (S)SS → ((S))SS → ((SS))S(S)
→ ((()S))S(S) → ((()()))S(S) → ((()()))()(S)
→ ((()()))()(())

I am not sure what goes wrong with my answer? Is it necessary to use first production rule twice? Could anybody help me with this.

  • 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-18T19:40:33+00:00Added an answer on May 18, 2026 at 7:40 pm

    When I tried to solve this problem I start with start symbol

    What problem? The wikipedia article doesn’t pose any problem. It just shows a grammar describing the language of well-matched parentheses and gives an example of a word in that language and how to derive it.

    S-> SS -> (S)S-> ()S-> ()(S) -> ()() 
    

    That’s a perfectly valid derivation.

    but when I looked the answer, it was like this

    That’s not the answer (there was no question). It’s just an example.

    I am not sure what goes wrong with my answer?

    There’s nothing wrong with your derivation. Both ()() and ((()()))()(()) are valid words in the language.

    Is it necessary to use first production rule twice?

    You can apply the production rules as often as you want (assuming of course the non-terminal you want to replace is present in the term) and in any order you want. It all just depends on which word you want to derive.

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

Sidebar

Related Questions

I’m studying for Microsoft Certification exams and I came across a situation with a
I was studying some code I found on the web recently, and came across
I am studying to use MVVM pattern for my Silverlight application. Following code is
I just started studying C++, and I met this new guy: ->. I was
I've been studying C++ for a test and I am currently stuck with pointer
We are studying how to parse through the DOM tree in Java. Quick question,
I am studying about regular expression and struck with the lookaround concept and with
I am studying Forth for a personal project I have on my mind. It
When I was studying MySQL I have been asked by my Teacher to find
I am using these technologies: SQL Server 2005, ASP.NET MVC, NHibernate/sharp architecture and would

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.