There's an array of values from 1 to n. It isn't sorted. We have to sort it, but there are only to ways to move: third element to beginning or last element to beginning. How to do that ?
Name:
Anonymous2010-10-24 16:40
>>19
2 1 3 4:
3 2 1 4 (case 3)
1 3 2 4 (case 1)
2 1 3 4 (case 3) (failure)
(I did my solution intuitively - not working with an algorithm.)