0

How many n digits base $3$ numbers do exist such that they never contain pattern '$20$'? (first find a recurrence relation)

Emad
  • 115

1 Answers1

2

Hint: Let $a(n)$ be the sequence we are looking for. Let $b(n) , c(n), d(n)$ be the number of ternary strings (and so they can start with 0) which do not contain the pattern '20', and start with 0, 1 and 2 respectively.

What equations can you get?

Claim: $a(n) = b(n) + c(n) + d(n)$.
Claim: $b(n) = c(n) = b(n-1) + c(n-1) + d(n-1)$.
Claim: $d(n) = c(n-1) + d(n-1)$.

Can you take it from here?

$b(n) = a(n-1)$, $d(n) = a(n-1) - b(n-1) = a(n-1) - a(n-2)$. Hence ...

Calvin Lin
  • 68,864
  • I need recurrence relation in a form like this: A(n)=bA(n-1)+c – Emad Feb 04 '14 at 22:24
  • @Emad Yes, and it's a short skip to the end, which you can finish out. Note that the recurrence relation could involve more terms than just 2, which is why I asked you to guess what it looks like first. It will be of the form $a(n) = Ba(n-1) + Ca(n-2) + D$, where $B, C, D$ are constants. – Calvin Lin Feb 04 '14 at 22:28
  • Thanks for your help Dear @Calvin:) – Emad Feb 04 '14 at 22:32