reshown by
1,027 views

1 Answer

Best answer
9 votes
9 votes

Length 1: only one string - "a"

Length 2: "aa", "bb" - 2 strings

Length 3: "aaa", "bba", "abb"

Length (n) = Length (n-1) + Length(n-2),

as we get a string of length $n$, by appending "a" to a string of length $n-1$ as well as by appending "bb" to a string of length $n-2$. (This works only because 'a' and 'bb' doesn't have a common character). 

So, 

n No. of strings
1 1
2 2
3 3
4 5
5 8
6 13
7 21
8 34
9 55
10 89

We get no. of strings = 89 (10th Fibonacci number) 

selected by

Related questions


Deprecated: Implicit conversion from float-string "1701695702.728" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1701695702.728" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1701695702.728" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1701695702.728" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803
6.6k
views
2 answers
3 votes
Akriti sood asked Nov 7, 2016
6,567 views
A palindrome is a string whose reversal is identical to the string. How many bit strings of length n are palindromes? 2⌈n⁄2⌉ 2(⌊ n/2⌋ ) 2⌈n⁄2⌉ -1 2(�...
147
views
0 answers
0 votes
Md Sazzad asked Dec 23, 2023
147 views
How many strings are there of lowercase letters of length four or less, not counting the empty string?
Total PHP MySQL Other RAM
Time (ms) % Time (ms) % File count Time (ms) % Query count Time (ms) % Amount %
Setup 4.0 3% 2.4 2% 72 1.6 1% 2 0.0 0% 569k 49%
Control 12.8 11% 1.4 1% 5 11.7 10% 12 0.0 0% 224k 19%
View 1.5 1% 1.5 1% 12 0.0 0% 0 0.0 0% 81k 7%
Theme 88.5 79% 4.1 3% 15 84.5 75% 3 0.0 0% 264k 23%
Stats 4.6 4% 0.1 0% 0 4.6 4% 1 0.0 0% 0k 0%
Total 111.5 100% 9.4 8% 104 102.4 91% 18 0.0 0% 1141k 100%