Friday 6 December 2013

Sorting Algorithm Efficiency Review - Week 10

    As part of a review for the final exam I'll write about the efficiency's of different sorting algorithms in reference to their Big-Os. First we have selection sort, it is nice to know as it is simple, it finds the largest or smallest element and puts it into a sorted list and take it out of the unsorted list until the unsorted list is empty. It has efficiency O(n^2) as it is usually a nested for-loop. Second, merge sort, I always liked merge sort because the idea seemed clever. It splits the list in two repeatedly and then merges them together, called a "divide and conquer algorithm. It has efficiency O(n logn) as it is a recursive call on a split of base 2. Lastly, there is quick sort (my least favorite). Good for lists usually as it has O(n logn) for best case scenarios, but in worst case it has efficiency O(n^2), it picks an element then compares it to all others and inserts it. Comparing these three, the best would be merge sort as it consistently is O(n logn), then quick sort as it sometime is great, and then lastly selection sort as it always goes through the whole list with O(n^2). 

And to top it off a cool video on all the sorting algorithms: 



No comments:

Post a Comment