Minimum amount of swaps needed to sort a stack Given a stack, what is the minimum amount of swaps needed to sort it?
Since the bottom of it stays intact and we slowly move to the upper part of it, if the stack contains n elements, the amount of swaps f(n) would be 


  f(n) &lt; n


for n = 1, 2, 3, 4, is that correct? I cannot find a more accurate way to express it.
Also, how do we calculate the f(n) for n > 4?
Your problem is known as Pancake sorting and it is not true that $f(n) &lt; n$. The minimum number of swaps is between $\frac{15n}{14}$ and $\frac{18n}{11}$.

Currently we know empirically that $P_{17} = 19$, which is the Pancake number, giving lower bound of 19 flips in the stack of 17 elements.

The sequence is known as AA058986.