Given an alphabet of 3 letters i.e. a,b,c evaluate
the number of n-letter words containing even number
of “a”s.
The set of words can be built recursively. Let t(n) be the number of n character words containing even number of “a”s and let s(n) be number of n character words containing odd number of “a”s.
Then a word in t(n) can be formed taking a word from t(n-1) and appending "b" or "c" or by taking a word from s(n-1) and appending "a". Similarly, a word in s(n) can be formed taking a word from s(n-1) and appending "b" or "c" or by taking a word from t(n-1) and appending "a".
Then we have a double recursion t(n) = 2*t(n-1) + s(n-1) and s(n) = 2*s(n-1) + t(n-1). We also know that there are 3^n total words of length n, so s(n)+t(n) = 3^n.
Substitute s(n)+t(n) = 3^n into the recursion equations to get t(n) = t(n-1) + 3^(n-1) and s(n) = s(n-1) + 3^(n-1). Then subtract these two equations to get t(n) - s(n) = t(n-1) - s(n-1). This final relation can be iterated upon itself to get t(n) - s(n) = t(n-1) - s(n-1) = .... = t(0) - s(0).
The empty string is the unique word of zero characters, and has zero "a"s which is even. So t(0)=1 and s(0)=0. Then t(n)-s(n) = 1.
Treat s(n)+t(n) = 3^n and t(n)-s(n) = 1 as a system of equations and solve. Then t(n) = (3^n + 1)/2 and s(n) = (3^n - 1)/2.