
Sorting Given a sorted array, we can leverage binary search to make an efficient set data structure.
Stable Sorting A sorting algorithm is stable if the relative order of elements with the same key value is preserved by the algorithm Example application of stable sort Assume that names have been sorted …
• Divide and Conquer is more than just a military strategy, it is also a method of algorithm design that has created such efficient algorithms as Merge Sort.
The optimal (i.e., best possible) sorting algorithm can be modeled as a a perfect binary decision tree where ‣ each internal node compares two keys ‣ each leaf is a correct permutation of the input keys
Two slightly better O(n2) algorithms are Selection Sort and Insertion Sort.
- [PDF]
Sorting - Codility
Generally, sorting algorithms use very interesting ideas which can be used in other problems. It is worth knowing how they work, and it is also worth implementing them yourself at least once.
When analysing sorting algorithms, we consider: n: the number of items (hi lo + 1) C: the number of comparisons between items S: the number of times items are swapped