I am have problems with these examples: 1. define a grammar for the non-terminal
ID: 3608686 • Letter: I
Question
I am have problems with these examples:
1. define a grammar for the non-terminal symbol "language", suchthat a sentence of the language is consist of a nonempty, evenlength, sequence of z characters.
<language> ->How do I represent non-empty and evenlength?
2. define a grammar consisting of all strings which starts witha p character, followed by one or more q characters, followed by ar character.
<strings> -> <p><q>|<qq..><r>This is my interpretation but I am not sure.
Explanation / Answer
1.answer of first part sentence of the language that consist of a nonempty, evenlength, sequence of z characters is given below (zz)* zz this will accept all evennumber of z, and this will never be empty i have used * which is called kleene star notation, i.e,repeatition Kleene star mean (zz)* ={ null,zz, zzzz, zzzzzz ,..........} 2.second partp q q*r q* means { null ,q,qq,qqq,.................} you are right , your string is also correct
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.