in Algorithms retagged by
952 views
3 votes
3 votes

 

in Algorithms retagged by
952 views

4 Comments

 Prince Sindhiya 

where did u get this question from???

0
0
What is the answer given ..

Is it O(n²) or O(${2^n}$). ??
0
0
Please add the source of question
0
0

1 Answer

0 votes
0 votes
For 0 bits(empty letter) : 1 possibility

For 1 bit : 0, 1 : 2 possibilities

For 2 bits : 00, 01, 10 : 3 possibilities

For 3 bits : 000, 001, 010, 100, 101 : 5 possibilities

For 4 bits : 8 possibilities

So to generalise, T(n) = T(n-1) + T(n-2) which accounts for O(2^n).

Related questions

1 vote
1 vote
1 answer
1
1 vote
1 vote
0 answers
2
0 votes
0 votes
1 answer
4