Examples _best_ — Cfg Solved

( L = ) All strings over a,b where ab is not a substring.

( L = ( a^n b^n )^* )

: [ S \Rightarrow SS \Rightarrow (S)S \Rightarrow ((S))S \Rightarrow (())S \Rightarrow (())(S) \Rightarrow (())() ] cfg solved examples

Does every 'a' need a corresponding 'b'? Use S→aSbcap S right arrow a cap S b Identify Symmetry: Is it a palindrome? Use S→aSacap S right arrow a cap S a Check for ( L = ) All strings over a,b where ab is not a substring

: ( w \in a,b^* \mid w = w^R )

Eliminate terminals on the right side (introduce new non-terminals). cfg solved examples