Sorting
Stable and not-stable sorting
If after sorting, the sequence of the content does not change, it is known as stable sorting.
If after sorting, the sequence of the content changes, it is known as not-stable sorting.
Sorting is arranging data in a specific format, the most common formats being numerical and lexicographical.
Some real-life examples of sorting are:
- Telephone directory
- Dictionary
Sorting helps in data searching in the most efficient way, as the data is stored in an organized manner. It is also used to keep data in a more readable format.
In-place sorting and not-in-place sorting
Sorting algorithms that do not require any extra space for comparisons and temporary storage is known as in-place sorting.
On the other side, some sorting algorithms require space, they are known as not-in-place sorting.
Stable and not-stable sorting
If after sorting, the sequence of the content does not change, it is known as stable sorting.
If after sorting, the sequence of the content changes, it is known as not-stable sorting.
Adaptive and non-adaptive sorting
A sorting algorithm is considered adaptive when it is able to use already-sorted elements as an advantage in a list to be sorted. If the list has no more than one element that is already sorted, then it will not attempt to re-order them again.
Non-adaptive algorithms try to force every single element in a given set to be re-ordered to confirm it is sorted.
Reference
