I've tried but I can't figure out any solution. Is there any hint for me to solve the question?

  • $\begingroup$ There are three pieces. One for $j=0$. One for $j=1$. One for $j\ge2$. Find the CFG for each piece. Then you get $S\to S_1\mid S_2\mid S_3$. $\endgroup$ – John L. Mar 13 '19 at 1:08
  • 3
    $\begingroup$ Please read how to ask a good homework question. Besides an explicit question, it is expected of you to show your partial progress, thoughts and/or where you got stuck. It will help draw more better answers faster. Otherwise, this post might be closed or downvoted. $\endgroup$ – John L. Mar 13 '19 at 1:12
  • $\begingroup$ My apologies, I am new here and haven't read the rules. I have solved the questions and uploaded my answer. $\endgroup$ – Martin Chou Mar 13 '19 at 4:22
  • 1
    $\begingroup$ @MartinChou Please undo your edits and post an answer to your question instead. $\endgroup$ – orlp Mar 13 '19 at 7:42

$ S =>S_1 \mid S_2 \mid S_3 $

$ S_1 =>AC $

$ S_2 => aS_2c \mid b $

$ S_3 => AbbBC $

$ A =>aA \mid epsilon $

$ B =>bB \mid epsilon $

$ C =>cC \mid epsilon $

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.