Alternating permutation (source code)

= Alternating permutation

With the upward-starting convention, an alternating permutation of $\{1,\ldots,n\}$ has one-line entries satisfying
$$
a_1<a_2>a_3<a_4>\cdots.
$$
For $n=3$, the possibilities are $132$ and $231$. Reversing every inequality gives the downward-starting convention; complementing each label by $a\mapsto n+1-a$ is a bijection between the two conventions.

These permutations are counted by the <Euler zigzag numbers> for one fixed initial direction. For $n\geq2$, counting both directions doubles that count. For lengths zero and one, the inequality condition is vacuous, so the direction classes coincide instead.

Alternating refers to the succession of inequalities, not to membership in the <alternating group>. For example, $132$ is upward alternating but is an odd permutation: it swaps two labels. This distinguishes an order pattern from permutation parity.