Context Free Grammar from Language

87 Views Asked by At

I'm given the language M = {c^m d^n | 2m > n > m} and need to find a context free grammar for it

What I came up with are the 2 production rules: S -> ccTddd T -> cTdd | ϵ

This however doesn't take into account for combinations where n = m + 1. Any ideas on how I can cover all possibilities where 2m > n > m?

I also need to create a parse tree for the string c^4 d^6, and I'm kind of lost on how to go about doing this.