This homework assignment will test your knowledge of context-free grammars (CFGs) and parsing, which you have learned in class. Please submit your assignment via Gradescope by the deadline. This is an individual assignment, and all answers must be typed. However, you are allowed to hand-draw any parse trees and scan and attach them in your final submission.
1. (8 Points) For each of the following context-free grammars, state the number of valid inputs supported by that grammar. As an example, the grammar G : E ! a j b j c results in 3 valid inputs—a, b, and c. Note that the empty string may be a valid input wherever applicable (this means that if an empty string is a possible input, you should consider it as part of your total count). You also do not need to list the different possible inputs.
2. (8 Points) Suppose there is a context-free grammar G such that the language of G, L(G), supports palindrome inputs, where inputs consist of characters from the alphabet = fa; c; e; rg.
Examples of valid inputs for L:
• The empty string
Examples of invalid inputs for L:
• race (not a palindrome)
• abcba (b = 2 )
• ack (composite of the ﬁrst two cases)
(a) (6 Points) Construct G.
(b) (2 Points) Is L a regular language? Explain why or why not.
EasyDue™ 支持PayPal, AliPay, WechatPay, Taobao等各种付款方式!
E-mail: email@example.com 微信:easydue