You cannot define an algorithm given this specification.
(ie. you cannot determine when to stop).<p>Take for example the list (1 2 3 1 2 3 1 2 3) with min=1 and max=3.
Notice that there is no operation giving you the number of element of the list, and no operation giving you access to the elements of the list: you cannot copy elements to a temporary storage, or replace one element for example with a guard value such as min-1.<p>Therefore you can only call compare, which tells you whether the first and second elements are in order or not, and from that you can only swap or not.  Then to make progress, you have to rotate.
You can count the number of rotate and the number of swaps, and if you knew the total number N of elements in the list, you could say that after N-1 negative compare your list is sorted.<p>But since you don&#x27;t know N, you cannot stop.  Since you cannot read the elements of the list, you cannot even know that you&#x27;ve reach one of the min (if you knew N you could know that even without reading, by noticing that you always had to swap to keep it, but you don&#x27;t).<p>Your code cheats, since it&#x27;s use the length of the list (it&#x27;s not one of the three operations allowed).