Number of zigzag permutations of first $n$ natural numbers given start and end value

244 Views Asked by At

Given $n$ and $1\le s,e\le n$, how to compute the number of zigzag permutations of first $n$ positive integers starting with $s$ and ending with $e$? I tried formulating a recurrence relation but can't come up with anything. (A permutation $a_1,...,a_n$ is zigzag if $a_1>a_2<a_3>a_4...$ or $a_1<a_2>a_3<a_4...$).

I found that Entringer numbers $E_{n,n}$ gives the number of alternating permutations ($a_1>a_2<a_3...$) of $n+1$ numbers starting with $k+1$. Defined by $E_{0,0}=1,E_{n,0}=0$ for $n\ge 1$ and $E_{n+1,k+1}=E_{n+1,k}+E_{n,n-k}$ otherwise. But this doesn't take care of the end value.