Saturday, 30 November 2013

Sorting Algorithms and Efficiency

sorting is the process of structuring data in a prescriptive arrangement and a vital technique for keeping things in a specific order . Even though all sorting algorithms share the commonality of comparing two values in order to see which is larger, the steps they take to analyze and contrast values are what makes them so different. 

In selection sort, the list is split into two parts, one portion consisting of elements that have already been sorted , and the remaining portion consisting of items that have not been sorted yet.The computer recognized  the sorted and unsorted portion by  placing a break point before the first element then  repeatedly searching for the smallest/largest element in the unsorted portion, swaps it with the first element in the unsorted section and moves the break point one step to the right.

Merge sort is a sorting algorithm that uses a ‘divide and conquer’ approach to sort  data items. First, it recursively divides the array into two sub-arrays and sorts them until the sub-arrays each contain a single element.
Quick sort is a recursive sort that also adopts an effective ‘divide and conquer’ strategy but noticeably differs from Merge sort because it does not require more storage .A quick sort first marks a pivot value then divides the array into two parts, one section consisting of values smaller than the pivot value, the other consisting of values larger than the pivot value. When this process ends, the pivot value is then placed in the middle of these two parts, bringing everything together.


Efficiency is a fundamental part of computer science and, as we've learnt throughout this semester, developing a solution to a problem is not enough. We also want to do this efficiently. Even though there are several sorting algorithms, we want to implement a sorting algorithm that achieves maximum productivity with the least amount of effort and time. The efficiency of an algorithm is often conveyed by the amount of time it takes to run in relation to its input and order. The order can be expressed with the capital letter 'O', a representation dubbed ‘Big-O notation’ which is a common way of representing algorithm efficiency. 

No comments:

Post a Comment