This week I continued to learn about many sorting methods - from the most optimal to the worst. In lecture, we compared runtimes of various sorting methods and determined the runtime at the best case and the worst case. Comparing sorting algorithms, you see that some preform optimally under certain conditions like a small or random list, while other sorting algorithms excel at sorting longer lists when compared to others (like sorting algorithms that are logarithmic outperform those that are quadric by a long shot). With this in mind, I always wondered if there could be a hybrid algorithm that takes the best characteristics of two algorithms. It turns out that Timsort does just this, it is a hybrid sorting algorithm derived from insertion sort and merge sort. At the worst case, Timsort is within big O of nlogn and at best case it has a constant runtime (within big O of n). In the lab this week, I had to return an inorder linked list that shows the tree from the furthest left node to the furthest left, to do this we used two helper functions within the main function and recursion. For the second part of the lab, we had to write a method for the longest path, I found this to be more challenging. This week was all about sorting algorithms.
No comments:
Post a Comment