(String[] args)
| 29 | } |
| 30 | public class WiggleSorting { |
| 31 | public static void main(String[] args) { |
| 32 | // What is wiggle sort? |
| 33 | // 1.To sort an array in waveform. |
| 34 | // 2.The array’s elements shall be ordered such that, |
| 35 | // arr[0]<arr[1]>arr[2]<arr[3] and so on in wiggle sort.(Even index have smaller value and odd |
| 36 | // index having larger values) |
| 37 | //Time complexity : average O(n) time . |
| 38 | |
| 39 | |
| 40 | |
| 41 | Scanner sc = new Scanner(System.in); |
| 42 | System.out.print("Enter the number of elements of required array :"); |
| 43 | int n= sc.nextInt(); |
| 44 | int[] arr= new int[n]; |
| 45 | System.out.println("Enter the array(enter only positive integer):"); |
| 46 | for(int i =0; i<n; i++){ |
| 47 | arr[i]=sc.nextInt(); |
| 48 | } |
| 49 | SortWave ob = new SortWave(); |
| 50 | ob.sortInWave(arr, n); |
| 51 | for (int i : arr) { |
| 52 | System.out.print(i+" "); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 |
nothing calls this directly
no test coverage detected