Suppose you are given an array of integers. How will you sort the array into alternative order?
The algorithm works as :
Time to sort the array is \( O(nlogn) \) and to swap is \( O(n) \). Therefore, overall time complexity = \( O(nlogn) \). public static void sortInAlternateOrder(int[] array){ |