Respuesta :
Answer: Denote by [tex]a_n[/tex] the number of ternary strings of length n
- a) [tex]a_n=2(a_{n-1}+a_{n-2})[/tex] for all [tex]n\geq 3[/tex].
- b) [tex]a_1=3, a_2=8[/tex]
- c) 284
Step-by-step explanation:
a) Let [tex]S=x_1 x_2\cdots x_{n-2} x_{n-1} x_{n} [/tex] be a ternary string of length n. If [tex]x_{n}=1[/tex], then S can be decomposed as [tex]S=L1[/tex] where [tex]L[/tex] is a ternary string of length n-1 with no consecutive zeros. In this case, there are [tex]a_{n-1}[/tex] choices for [tex]L[/tex] therefore the number of strings S which last is digit 1 is [tex]a_{n-1}[/tex]. Similarly, the number of ternary strings S with [tex]x_{n}=2[/tex] is [tex]a_{n-1}[/tex]. We conclude that the number of strings S whose last digit is 1 or 2 is [tex]2a_{n-1}[/tex]
Now, if [tex]x_{n}=0[/tex], then [tex]x_{n-1}=1[/tex] or [tex]x_{n-1}=2[/tex] because S does not have consecutive zeroes. Then [tex]S=P10[/tex] or [tex]S=P20[/tex] where [tex]P[/tex] is a ternary string of length n-2 with no consecutive zeros. Thus, the number of such strings S is equal to the number of strings P whose last digit is 1 or 2 is [tex]2a_{n-1}[/tex]. Applying the same reasoning from before, this number is equal to [tex]2a_{n-2}[/tex].
Any string S has its last digit equal to 0,1 or 2 then by the sum rule, [tex]a_n=2a_{n-1}+2a_{n-2}=2(a_{n-1}+a_{n-2})[/tex].
b) 0,1,2 are the strings of length 1 with no consecutive zeroes. Then [tex]a_1=3[/tex]. The corresponding strings of length 2 are 01,02,10,11,12,20,21,22, thus [tex]a_2=8[/tex].
c) This follows froma applying the recurrence relation repeatdly. [tex]a_6=2a_{5}+2a_{4}=2(a_4+a_3)+2a_4=4a_4+2a_3=8(a_3+a_2)+2a_3=10a_3+8a_2=20(a_2+a_1)+8(a_2)=20(11)+8(8)=284[/tex].