TITLE: Dealing cards numbered $1$ to $n$ into piles
QUESTION [5 upvotes]: Is anything known about the following?
I hold in my hand a shuffled pack of cards numbered $1$ to $n$. One by one, I place them all, face up, on a table in piles. For each card I deal from my hand, say card numbered $k$, I open a new pile only if the top card of an existing pile is not $k + 1$; otherwise I place that card on top of that pile. If at any stage (before dealing a new card) the bottom card of an existing pile is one less than the top card of another pile, I combine the two into a new pile in the obvious way.

What is the most likely maximum number of piles that will be formed at some stage while so dealing the $n$ cards?

What is the expected maximum number of piles that will be formed at some stage while so dealing the $n$ cards?


In both cases, count piles only if no two piles can be combined into one.

REPLY [3 votes]: At Timothy Chow's request, here is a table of $A(n,m)$, the number of permutations in $\mathfrak{S}_n$ with maximum number of piles equal to $m$. Note that clearly $A(n,m)=0$ if $m > \lceil n/2 \rceil$:
$ \begin{array}{c|c c c c} n/m & 1 & 2 & 3 & 4 & 5 \\ \hline
1 & 1 \\
2 & 2 \\
3 & 4 & 2 \\
4 & 8 & 16 \\
5 & 16 & 92 & 12 \\
6 & 32 & 472 & 216 \\ 
7 & 64 &  2312 & 2520 & 144 \\ 
8 & 128 & 11104 & 24480 & 4608 \\ 
9 & 256 & 52880 & 216432 & 90432 & 2880 \\
10 & 512 & 250912 & 1815264 & 1418112 & 144000 \end{array}$
There are certainly some patterns visible, but the whole triangle does not appear to be in the OEIS.