2014年3月27日星期四
Sort and efficiency
The process of this lesson is going to the final part. This semester, I learned further and deeper knowledge concerning Python programming. In the previous two weeks, we studied the serious kinds of sort problems, which is quick sort, merge sort, count sort, insertion sort and selection sort respectively. After this week's final lab, I got some useful conclusions involving the efficiency of each sort algorithm. Insertion, selection and bubble sort are all based on O(n^2). Moreover, bubble sort is the simplest method to sort series,but it is with the worst algorithm in the fundamental sort cases because this algorithm need to check every two-continuous groups in the series. As the results, those three sort methods ,insertion, selection and bubble, are very original way. Another three sort methods, except count sort, are based on O(lg(n)) and similar to use binary method. Quick sort is a unstable sort when I do some research on the Internet. Actually, it's average worse performance is exactly O(lg(n)). However, when encountering the worst case where is useless to use binary method, it returns to O(n^2). On the contrary, merge sort is a stable method and always under O(lg(n)). In my opinion, this is the most efficiency case of those fundamental sort methods. The last sort method called count sort is like a linear method according to O(n+k). This sort algorithm only uses restricted series that must obey to continuous numbers. After calculating sketchily, series with less than approximately 100 elements has more quick speed than the algorithm that based on O(lg(n)).
订阅:
博文评论 (Atom)
没有评论:
发表评论