Sunday, 30 March 2014

Week 11

Sorting and Efficiency

We went over some sorting algorithms. We learned select sort, bubble sort, quick sort, merge sort and count sort. Each sorting algorithms have different efficiency. In all cases (best, average and worst), running time of merge sort is O(nlogn) which is short compared to other sorting algorithms. Sorting algorithm is more efficient when running time is shorter. Looking at selection sort which is least efficient of the 5 sorting algorithms, the running time for all cases is O(n^2). Running time for insertion sort in best case is O(n) and in average and worst case, it's O(n^2) which is again, not as efficient as merge sort.

No comments:

Post a Comment