How to find the recurrence relation of an increasing-decreasing sequence?

21 Views Asked by At

The question is: If we have a sequence of $n$ numbers from $1$ to $n$, and we have: $a_1 < a_2$ and $a_2 > a_3$ and $a3 < a4$ and so on, alternating between increasing and decreasing, what is the recurrence relation describing the number of such sequences?

My solution: Let $A_n$ be the number of such sequences with $n$ numbers. now, assuming $n \ge 3$, we can remove $n$ and $1$ from the sequence, and rename every digit such that the smallest is $1$, the second smallest is $2$, etc. then, the number of ways to put these numbers in increasing-decreasing order is $A_{n-2}$.

After reverting back to the original digits, All that is left is to put $n$ and $1$ back in the sequence. We can only put $1$ in the odd positions between the digits (of which there are $n+1$), since it will always be smaller than the number after it, and we can only put $n$ in the even positions between the digits, since it will always be bigger than the number after it.

This means we have split the relation into $2$ cases, one where there $n$ is odd, in this case, the number of odd and even positions (between the digits) is the same, equal to $\frac{n-2}{2}$.

$$A_n = \frac{{(n-2)^2}}{4}A_{n-2}$$

by the product rule, there are $\frac{n-2}{2}$ ways to put $1$ in, and the same for $n$.

if $n$ is even, the even positions are one short of the odd positions, giving: $$A_n = \frac{n-2}{2}(\frac{n-2}{2}-1)A_{n-2}$$

Is this correct?