C++
What does it mean for a sorting algorithm to be "stable"?
Wikipedia has a list of all known sorting algorithms. Which one's average is the worst and what is its Big O? (I just wanted to make you see that list.)
A sorting algorithm is said to be stable if the output of the algorithm is same as the array would have been sorted in ascending or descending order. It preserves the order of record which have the equal keys. A stable algorithm is used to solve any small errors.
The sorting algorithm which has the worst average case complexity are:
1) Insertion Sort O(n2)
2) Selection Sort O(n2)
3) Cycle Sort O(n2)
4) Strand Sort O(n2)
5) Cocktail Shaker Sort O(n2)
6) Comb Sort O(n2)
7) Gnome Sort O(n2)
8) Odd even sort O(n2)
All these sorting algorithms have the worst average case complexity with Big O as O(n2)
If you liked the solution then give a thumbs up ? it will be really appreciated ?
Get Answers For Free
Most questions answered within 1 hours.