In python, sorting is a method that is usually used to organizes a collection of objects. It is very common to confront some sorting issues in our "daily programming life", and to be honest, we can say it was sorting that actually achieved what Google is (of course, there is no doubt that it is impossible to list all of this kind of examples).
I believe that sorting could not be categorized into just a few classes, yet I have only encountered 7 kinds of them. Quick sort is essentially based on the idea of choosing a pivot and sorting the partitions which are made by the pivot and where it goes. Merge sort always cuts a list in half and then merge the sorted results. All kinds of sorting method have their own shorts and strengths, and it really depends on the efficiency of the sorting method.
To compare their efficiency, we compute a way called big-oh to estimate their running time along with the increasing of the input, and it appears as following:
O(1) < O(log n) < O(n) < O(n log n) < O(n^2) < O (2^n) < O (n!) < O(n^n)
No comments:
Post a Comment