MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / main

Method main

Programs/WiggleSorting.java:31–54  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

29}
30public 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

Callers

nothing calls this directly

Calls 2

sortInWaveMethod · 0.95
printMethod · 0.80

Tested by

no test coverage detected