Have you already chosen a sorting #algorithm?
I admit that the exercise is not one of the least, the sorting algorithms, there are dozens of them and everyone has their say.
Having almost all studied, one of the choices that I retain is the algo of #TimSort.
Timsort is an efficient sorting algorithm for real-world data. Created by Tim Peters and adopted in 2001 as the default sorting algo in the #Python programming language. Timsort first analyzes the list it is trying to sort, then chooses an approach based on the analysis performed.
The initial array is divided into sub-arrays called #RUN on which insertion sort is applied (insertion sort); and then merge sort on each of its RUNs to return to the initial array.
NB: The value of RUN may vary depending on the size of the initial array.
This algo allows you to have an order #complexity of O(n log n) in a worse case and a complexity of O(n) in a best case.
An implementation in C using the double linked lists that I made of this algo can be found in the Link
Your feedback is welcome in the comments.
Top comments (0)