Minimizing the number of writes is useful when making writes to some huge data set is very expensive, such as with EEPROMs or Flash memory, where each write reduces the lifespan of the memory.

Among the sorting algorithms that we generally study in our data structure and algorithm courses, Selection Sort makes least number of writes (it makes O(n) swaps). But, Cycle Sort almost always makes less number of writes compared to Selection Sort. In Cycle Sort, each value is either written zero times, if it’s already in its correct position, or written one time to its correct position. This matches the minimal number of overwrites required for a completed in-place sort.

Sources:

http://en.wikipedia.org/wiki/Cycle_sort

http://en.wikipedia.org/wiki/Selection_sort

## Recommended Posts:

- Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted
- Stability in sorting algorithms
- Lower bound for comparison based sorting algorithms
- Given a number, find the next smallest palindrome
- Pancake sorting
- A Pancake Sorting Problem
- Find number of pairs (x, y) in an array such that x^y > y^x
- Find memory conflicts among multiple threads
- Rearrange an array in maximum minimum form | Set 1
- External Sorting
- Find minimum difference between any two elements
- Cartesian Tree Sorting
- Sorting 2D Vector in C++ | Set 2 (In descending order by row and column)
- Minimum sum of two numbers formed from digits of an array
- Know Your Sorting Algorithm | Set 1 (Sorting Weapons used by Programming Languages)