Sunday, March 30, 2014

Algorithm and Efficiency

      In the past couple of weeks, we learnt how efficiency verifies between different algorithms; a good algorithms can provide extremely high efficiency. In this case, it is pretty important to understand algorithms and learn how to evaluate the efficiency of functions.
      We have learnt several sorting algorithms in class: bubble, insertion, selection, merge, quick etc. They are using different method of sorting and, of course, their efficiency are different. However, through the study and the understanding of these algorithms, I find that we shouldn't choose algorithms only base on their efficiency on the worst case, since sometimes our function would be used in some kind of specific data, and that might be not in worst case. Consequently, when we are choosing algorithms, we should consider both the efficiency of the algorithms and the condition of our target data or what our function our be used for. In another word, this means that it is not enough to remember the efficiency but also understand the algorithm itself. For example, even both selection and insertion sort's efficiency are both O(n^2) in average, but we if we test it precisely, we can find that insertion sort is still faster than selection sort. The reason is that big-Oh notation only give us a rough idea of run-time, selection sort's run-time is always longer then insertion sort's.

No comments:

Post a Comment