diff --git a/algorithms/CPlusPlus/README.md b/algorithms/CPlusPlus/README.md index 9fae1305..3d85290a 100644 --- a/algorithms/CPlusPlus/README.md +++ b/algorithms/CPlusPlus/README.md @@ -81,6 +81,7 @@ 12. [Binary Insertion Sort](Sorting/binary-insertion-sort.cpp) 13. [Merge Sort](Sorting/merge-sort.cpp) 14. [Wave Sort](Sorting/wave-sort.cpp) +15. [Cycle Sort](Sorting/cycle-sort.cpp) ## Strings diff --git a/algorithms/CPlusPlus/Sorting/cycle-sort.cpp b/algorithms/CPlusPlus/Sorting/cycle-sort.cpp new file mode 100644 index 00000000..00f3bb07 --- /dev/null +++ b/algorithms/CPlusPlus/Sorting/cycle-sort.cpp @@ -0,0 +1,127 @@ +// ***Cycle Sort*** +// This sorting algorithm is best suited for situations where memory write or swap operations are costly. +// it is In-place and not stable + +#include +using namespace std; + +void cycleSort(int arr[], int size) +{ + for(int cyclestart=0;cyclestart