There are $n$ students in the class. They stand in a line in front of the teacher, who is to divide them into any number of non-empty teams (in particular, the sets can be of size $1$ or $n$) and in each set appoint a captain. A team can only consist of students standing consecutively in the line. In how many different ways can the teacher do this?
Arrange a suitable equation or system of recursive equations and determine the general formula.
I belive that the same question was asked right here: Counting the number of ways to divide into teams - complicated
There's no concrete solution provided so I tried to get my own.
I calculated manually the numbers of sequences for some of the initial values of $n$:
- $a_1 = 1$ (because we can have just $1$ team and $1$ captain of that team)
- $a_2 = 1 + 2 = 3$ (because we can have $2$ teams in which case the captains are obvious or $1$ team in which case we need to choose the captain in one of $2$ ways)
- $a_3 = 1 + 2 \cdot 2 + 3 = 8$ (because we can have $3$ teams in which case the captains are obvious or we can have in $2$ ways $2$ teams of $1 + 2$ students in which case we need to choose the captain in one of $2$ ways or we can have one big team of $3$ students for which we need to choose the captain in one of $3$ ways)
- $a_4 = 1 + 2 \cdot 3 + 2 \cdot 2 + 3 \cdot 2 + 4 = 21$ (because we can have $4$ teams in which case the captain are obvious or we can have in $2$ ways $2$ teams of $1 + 3$ students in which case we need to choose the captain in one of $3$ ways or we can have in one way $2$ teams of $2+2$ students in which case we can choose $2$ captains in $2$ ways each or we can have in $3$ ways $3$ teams of $1 + 1 + 2$ students in which case we can choose captain in $2$ ways or we can have one big team of $4$ students for which we need to choose the captain in one of $4$ ways)
When we add one student in the line at the plece n, we have:
- one big team with n students (so we can choose the captain of that team in one of n ways) and...
- as many teams with captains as in the line of lenght n-1, but we have that one 'new student' alone in his own team and...
- as many teams with captains as in the line of lenght n-2, but we have that one 'new student' in a team of 2 (so we can choose the captain of that team in one of 2 ways) and...
- as many teams with captains as in the line of lenght n-3, but we have that one 'new student' in a team of 3 (so we can choose the captain of that team in one of 3 ways) and so on
Therefore, I thought that the recurrence equation would look like this:
$a_n = n + a_{n-1} + 2a_{n-2} + 3a_{n-3} +...$
As you can see while comparing with the numbers of sequences for some of the initial values of $n$ (those that I calculated manually above), the formula does work.
Now, from the comments below I know that the general formula needs to be of form: $a_n = 3a_{n-1} - a_{n-2}$
Could somebody explain to me how to get from: $$a_n = n + a_{n-1} + 2a_{n-2} + 3a_{n-3} +...$$ to: $$a_n = 3a_{n-1} - a_{n-2}$$ ?
I would like to see an algebraic way of transformation, not a proof by induction.