1For each of the following languages write a grammar that de

1.For each of the following languages, write a grammar that describes the language.

(a) The set of strings that begin with ab and end with ba, over alphabet {a, b}. Note: the string aba is in the language.

(b) The set of strings of parentheses ( ), brackets [ ], and braces { } that are properly nested. For instance, ( ) [ { } ( ) ] is properly nested, while ( [ ) ] is not.

Solution

1. S->abA | aba
A->aA | bA | ba

Strings like {aba , abba,abaaaaaaba , abbbba}



2. SSS | (S) | [S] | {S} |
Let me know if there is any concern
( ) [ { } ( ) ]
Taking this example


S->SS
S->()[S]
S->()[SS]
S->()[{}S]
S->()[{}()]
Thanks, Let me know if there is any concern.


-----------------------------------------------------------------
Small change as per request :_

2. SSS | (S) | [S] | {S} | () | [] | {}    (Updated the answer)

Thanks, let me know if there is anything.

1.For each of the following languages, write a grammar that describes the language. (a) The set of strings that begin with ab and end with ba, over alphabet {a,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site