Question
A pennant is a sequence of numbers, each number being 1 or 2. An n-pennant is a sequence of numbers with sum equal to n. For example, (1,1,2) is a 4-pennant. The set of all possible 1-pennants is {(1)}, the set of all possible 2-pennants is {(2), (1,1)} and the set of all 3-pennants is {(2,1), (1,1,1), (1,2)}. Note that the pennant (1,2) is not the same as the pennant (2,1). The number of 10-pennants is ______________.
Official answer and solution
- Accepted answers
- 88.9 to 89.1
- From
- Official GATE 2014 answer key
Solution
Set up a linear recurrence relation for the number of compositions of n into parts of size 1 and 2.
Let be the number of -pennants (ordered sequences of 1s and 2s that sum to ).
Consider the last number in an -pennant:
- If the last number is 1, the preceding sequence must sum to , which is an -pennant. There are such pennants.
- If the last number is 2, the preceding sequence must sum to , which is an -pennant. There are such pennants.
Therefore, satisfies the Fibonacci recurrence:
Given initial conditions:
- (sequence: (1))
- (sequences: (2), (1, 1))
- (sequences: (2, 1), (1, 1, 1), (1, 2))
Computing subsequent values:
Thus, the number of 10-pennants is 89.
89
Off-by-one errors in Fibonacci index (computing instead of ).
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2014 Computer Science and Information Technology (CS) Session 1
- Question
- 59 of 65, printed as CS Q.49
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.