Give a Context free grammar for
{w | w is an element of {a, b, c, d}* such that # of a+ # of b = # of c + # of D}
how do i approach this question...?
Give a Context free grammar for
{w | w is an element of {a, b, c, d}* such that # of a+ # of b = # of c + # of D}
how do i approach this question...?
How's about this one:
S -> A C S
S -> A S C
S -> S A C
S -> C A S
S -> C S A
S -> S C A
S ->
A -> a|b
C -> c|d
(There may be a more elegant solution...)
As to how to approach these, in my opinion the key insight is usually in the grouping (here A and C), but the I think the best way to learn is to see lots of examples and attempt lots of problems - e.g. this one.