I am studying the Dragon Book about compilers and it has exercises which I try to solve. Unfortunately, there is no-one nearby who could check my solutions. Is it appropriate to post my solutions here asking someone experienced to check them?

Some of the exercises do not require writing code (like this):

Exercise 2.2.1:
Consider the context-free grammar S -> S S + | S S * | a

a) Show how the string aa+a* can be generated by this grammar.
b) Construct a parse tree for this string.
c) What language does this grammar generate? Justify your answer.

Example of the answer

a) Show how the string aa+a* can be generated by this grammar.

  1. Let S1 = a according to the 3-rd production.
  2. From the 1-st production we get: S2 -> S1 S1 + => S2 = aa+
  3. From the 2-nd production: S3 -> S2 S1 * => S3 = aa+a*

We got the required string S3 using the rules of the grammar.

I asked the same question at https://softwareengineering.meta.stackexchange.com/questions/9573/is-it-appropriate-to-ask-to-check-exercises-from-dragon-book-here and was sent here.


1 Answer 1


In general, requests to verify solutions are discouraged, as the answers will not be able to say much more than yes or no, which won't help you or future visitors. The process of feedback to an exercise solution requires some back and forth, which is not suitable to this platform. See also here and here for more information.

That said, the material of the book certainly is on-topic here, so if the reason you're uncertain whether your solution is correct depends on a specific conceptual issue you're uncertain about, then you can ask about that, instead.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .