(By Warut Suksompong). For i=1,2,…,n−1, let si be the number of students hj with j<i such that hi+1,hj, and hi appear in that order on the circle. Note that si≤i−1 for all i. Now we take a look what happens when two students switch places.
* If hn is involved in the switch, sn−1 decreases by 1, while all the other si's remain the same.
* Otherwise, suppose ha and hb are switched. Then, we have a+1<b<n, so sb−1 decreases by 1, while sb increases by 1. All other si's remain the same.
Therefore, we see that the quantity M=∑i=1n−1(n−i)si decreases by exactly 1 after every switch. The number of switches until no more are possible is therefore at most the initial value of M. Because si≤i−1 for 1≤i≤n−1, this value is at most ∑i=1n−1(n−i)(i−1)=(3n).
Note. With this solution, it is also easy to see that the number of switches until no more are possible depends only on the original ordering.