Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.Write a grammar that generates strings that contain matched brackets and paren

ID: 645404 • Letter: 1

Question

1.Write a grammar that generates strings that contain matched brackets and parentheses. Examples of valid strings are:

Examples of invalid strings are:

2. Given the following grammar:

<sentence> -> <left> a <right> b
<left> -> <left> b | b
<right> -> a <right> | a

Indicate which of the following strings are valid according to this grammar. For those that are valid, construct the parse tree.

baab

bbbaaaaab

bbbab

aabab

bbbaaabb

In English, describe the strings generated by this grammar as specifically as possible.

Explanation / Answer

1.

<start> -> <start> <start> | [ <start> ] | { <start> } | ( <start> ) | NULL

2.

Valid:
baab, bbbaaaaab,

Invalid:
bbbab, aabab, bbbaaabb

The grammar generates strings which begin with a sequence of 1 or more 'b', followed by a sequence of 2 or more 'a', further followed by a 'b'

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote