Saturday, 22 March 2014

Week 10: More Big-Oh and Better Sorts

This week, we focused on more big-oh's and a bunch of new sorts including quick, merge, count, and python's own hybrid timsort. One of the sorts that stand out the most to me is quick sort. When I was younger, everybody says that quick sort is everyone's favourite sort but that was pretty much the only thing I know back then. Now, it is amazing to be able to analyse WHY it is everybody's favourite. The biggest difference between quick sorts and all the other sorts is that it chooses a pivot and begins to partition. Generally, it performs better than most sorts (eg. insertion sort with O(n^2)) because it does not rely on swaps and redundant calls. Thus, making quick sort as optimized as possible. Merge sort is pretty awesome too as it splits up elements and joining them together in pairs, quadruples, and so on. It seems like a pretty slow process but surprisingly, it results in O(nlg n).

Professor Heap showed us that we could compare different types of sorts by calculating the duration of each execution. I found it absolutely amazing because nothing beats being able to see the results before your own eyes. The cool thing is that it is not limited to just sorting algorithms but to any programs.

No comments:

Post a Comment