Consider the situation of making words with only three letters: a, b, and c. If the letters a and b cannot be arranged adjacent to each other, find the number of all words whose length is n.
Let An be the answer to find, and set A0=1. Also, trivially, A1=3.
Now, if n≥2, it can be classified as follows.
(1) There is c in the first position.
Excluding c, it is the same as the number of cases to create a word with the remaining n−1 letters.
So, An−1.
(2) c appears for the first time in the k-th position where 2≤k≤n.
a and b must appear alternately up to the k−1-th time.
Excluding the first k letters, the rest is equal to the number of cases to make a word with n−k letters.
So, 2An−k.
(3) There is no c.
The only two cases are acceptable: aba... and bab...
So, 2.
Putting together the above, the recurrence relation is as follows. AnAn−1An−An−1⟹⟹=An−1+2An−2+⋯+2A0+2=An−2+2An−3+⋯+2A0+2=An−1+An−2An−2An−1−An−2=0An+1−2An−An−1=0(n≥1)
This form of recurrence relation can be solved as a quadratic equation. It is the same process as finding the general term of the Fibonacci sequence. If this relation is transformed into the following quadratic equation, a simultaneous equation can be established by finding the two roots α and β of this equation. ⟹⟹An+1−2An−An−1=An+1−(α+β)An+αβAn−1=0x2−2x−1=0α=1−2,β=1+2,α+β=2,αβ=−1⟹⟹{An+1−αAn=β(An−αAn−1)An+1−βAn=α(An−βAn−1){An+1−αAn=βn(A1−αA0)=βn(3−α)An+1−βAn=αn(A1−βA0)=αn(3−β)(β−α)An=βn(3−α)−αn(3−β)
Since α=β, An=β−αβn(3−α)−αn(3−β)=β−αβn(1+β)−αn(1+α)=22(1+2)n(2+2)−(1−2)n(2−2)=2(1+2)n(2+1)−(1−2)n(2−1)=2(1+2)n+1+(1−2)n+1(n≥1)
Keep going!Keep going ×2!Give me more!Thank you, thank youFar too kind!Never gonna give me up?Never gonna let me down?Turn around and desert me!You're an addict!Son of a clapper!No wayGo back to work!This is getting out of handUnbelievablePREPOSTEROUSI N S A N I T YFEED ME A STRAY CAT