Improved main Description comment | Cycle Sort

This commit is contained in:
marsonya
2021-01-25 23:50:46 +05:30
parent 6c916966d6
commit 9515badb75

View File

@ -1,10 +1,10 @@
/*
Wikipedia says: Cycle sort is an in-place, unstable sorting algorithm,
a comparison sort that is theoretically optimal in terms of the total
number of writes to the original array, unlike any other in-place sorting
algorithm. It is based on the idea that the permutation to be sorted can
be factored into cycles, which can individually be rotated to give a sorted result.
*/
/**
* Cycle sort is an in-place, unstable sorting algorithm,
* a comparison sort that is theoretically optimal in terms of the total
* number of writes to the original array, unlike any other in-place sorting
* algorithm. It is based on the idea that the permutation to be sorted can
* be factored into cycles, which can individually be rotated to give a sorted result.
*/
function cycleSort (list) {
let writes = 0