Created: 2023-02-26 19:24
Status: #idea
Subject: Programming
Tags: C Algorithms
Sorting Algorithm Stability
A sorting algorithm is said to be stable when the order of equal values are maintained.
The root cause of UNSTABILITY is the SWAPPING of NON-ADJACENT elements.
Why Stability is Important
This is an example of a stable sort, Tanmay was inserted into the Database first, therefore, he must be first.
The Impossibility Trinity of Comparison Sorts
We can only pick 2 chracteristics to include in our sorting algorithm.
- Selection Sort is an anomaly because it only has
O(1)
Space Complexity characteristic, but it is UNSTABLE - so, it's better to use Bubble Sort or Insertion Sort instead.