next up previous
Next: Problem 2 - TLB Up: Information Science I Previous: Information Science I

Problem 1 - Context Free Grammars

Give a context free grammar that produces the following set:

1.
All palindromes (a sentence that is the same when read from beginning and read from the end) on the alphabet $ \{a, b \}$.
2.
All strings on the alphabet $ \{a, b \}$ such that $ a$ appears twice as many times as $ b$.


1.
A context-free grammar generating the set of palindromes would have the productions:

$\displaystyle S \rightarrow aSa \; \vert \; bSb \; \vert \; a \; \vert \; b \; \vert \; \epsilon $

2.
A context-free grammar generating the set of all strings on the alphabet $ \{a, b \}$ such that $ a$ appears twice as many times as $ b$ would have the productions:

$\displaystyle S \rightarrow aSaSb \; \vert \; aSbSa \; \vert \; bSaSa \; \vert \; \epsilon $



Reynald AFFELDT
2000-06-08