MCPcopy Create free account
hub / github.com/SR-Sunny-Raj/Hacktoberfest2021-DSA / cycleSort

Method cycleSort

06. Sorting/CycleSortInJava.java:10–22  ·  view source on GitHub ↗
(int[] arr)

Source from the content-addressed store, hash-verified

8
9 }
10 static void cycleSort(int[] arr)
11 {
12 int i = 0;
13 while (i < arr.length)
14 {
15 int correct= arr[i]-1;
16 if(arr[i]!=arr[correct])
17 swap(arr,i,correct);
18 else
19 i++;
20 }
21
22 }
23 static void swap(int[] arr,int a, int b)
24 {
25 int temp;

Callers 1

mainMethod · 0.95

Calls 1

swapMethod · 0.95

Tested by

no test coverage detected