I am just getting to recursion in one of my classes, and I'm a bit confused on how to go about generating a set of words and the notation.
Given the following question, how would I go about generating this set?
(assuming ∑={a,b}), the set of strings with twice as many a’s as b’s.
If I start by saying that λ∈T as my base case, how would I then generate the recursive case?
Edit: Please consider accepting @Brian M. Scott's answer as it is complete and more rigorous.
(Too large for a comment, but I hope it will give you some insight.)
Generate 2 $a$'s for each $b$. First, you have 3 possibilities ($1^{st}$ generation). $$ \mathbf{w}_1^1=aab, \ \mathbf{w}_2^1 = aba, \ \mathbf{w}_3^1=baa $$ Next, generate all the possible permutations of each previous $\mathbf{w}_i^1$, inserting each previous $\mathbf{w}_i^1$ at each possible place ($2^{nd}$ generation). For example: $$ \mathbf{w}_1^2 = aab|\mathbf{w}_1^1, \hspace{10pt} \mathbf{w}_2^2 = aba|\mathbf{w}_1^1, \hspace{10pt} \mathbf{w}_3^2 = baa|\mathbf{w}_1^1 \\ \mathbf{w}_4^2 = aa|\mathbf{w}_1^1|b, \hspace{10pt} \mathbf{w}_5^2 = ab|\mathbf{w}_1^1|a, \hspace{10pt} \mathbf{w}_6^2 = ba|\mathbf{w}_1^1|a \\ \large \dots $$
Note that you can insert multiple (previous) strings at different positions, for the next generation. You can go to the next generation only after you have enumerated all possible strings for the current generation, and this includes inserting multiple previous strings.
I have used the notation $u \ | \ v$ to denote the concatenation of $u$ and $v$, and $\mathbf{w}_i^j$ denotes the $i$-th word in generation $j$.
You can then derive a recursive formula for $\mathbf{w}_i^j$ using this.