0

I want to find a recursive formula to determine the amount of different words that you can build by taking n letters from the set {a,b,c}. Also, there needs to be atleast on occurence of two consecutive a's in the word. For example, baac is a valid word, but abac is not.

How would you approach this?

  • Well, there are $3^{n-2}$ words that start with $aa$. Similarly, there are $3^{n-2}$ word with $aa$ as the second and third characters... now continue shifting $aa$ to the right and sum up all the possible words you get $(n-1)3^{n-2}$. – TSU Jan 26 '21 at 18:52
  • @TSU That is incorrect. You have counted several of these multiple times. Note that for $n>10$ you have $(n-1)3^{n-2}>3^n$ – JMoravitz Jan 26 '21 at 18:56
  • As for a correct approach... it is easier to count the number which don't have any consecutive $a$'s via a recurrence relation and subtract that number away from the total. – JMoravitz Jan 26 '21 at 18:57
  • Wops, you are right! – TSU Jan 26 '21 at 19:03

0 Answers0