diff --git a/DSA_Codesheet/C/cycle_sort.c b/DSA_Codesheet/C/cycle_sort.c new file mode 100644 index 0000000..196b13a --- /dev/null +++ b/DSA_Codesheet/C/cycle_sort.c @@ -0,0 +1,77 @@ +#include +void cycleSort (int arr[], int n) +{ + // count number of memory writes + int writes = 0; + + // traverse array elements and put it to on the right place + + for (int i=0; i<=n-2; i++) + { + int item = arr[i]; + + int pos = i; + for (int j = i+1; j