(int[] arr, int a, int b)
| 5 | |
| 6 | // A utility method to swap two numbers. |
| 7 | void swap(int[] arr, int a, int b) { |
| 8 | int temp = arr[a]; |
| 9 | arr[a] = arr[b]; |
| 10 | arr[b] = temp; |
| 11 | } |
| 12 | |
| 13 | // This function sorts arr[0..n-1] in wave form, i.e., |
| 14 | // arr[0] >= arr[1] <= arr[2] >= arr[3] <= arr[4].... |