Saturday, November 30, 2013

Sorting Algorithms and Efficiency

So... It seems that this will be the last entry for this SLOG. It's been a pleasure to share my thoughts with you -I don't know if there's anyone else who reads these besides TAs though-. Today, I'll talk about some sorting algorithms and their efficiencies such as selection sort, quick sort and merge sort. First, the wikipedia articles about these sorting methods: -http://en.wikipedia.org/wiki/Selection_sort -http://en.wikipedia.org/wiki/Quick_sort -http://en.wikipedia.org/wiki/Merge_sort Needless to say what they do, I think the best sorting method among them is merge sort. How I came up with this idea lies on the worst-case performances of these sorting methods. Selection sort has a worst-case performance of n^2 (the worst among these three), where quick sort has n*log(n) and merge sort has n*lg(n). My knowledge until this point in Computer Science tells me that from these informations, it's safe to say that merge sort is the best one to use. Since it is such a good algorithm, Perl, Java and Python uses original or tuned copies of merge sort as their default sorting algorithm.

No comments:

Post a Comment