On a closer look, you can clearly see that as per my approach to the problem, I have defined something similar to the swap(i, j) operator. Given this operator, you can implement any O(n log n) sort that you desire.
swap(i, j) = reverse(i + 1, j), reverse(i, i + 1), reverse(i+1, j) Have fun implementing an O(n log n) sort! :) By the way, my approach should perform slightly better than standard heapsort with this swap operator on account of the fewer number of reverse and get operations. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/K0gKQ-hfOPsJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.