Friday, 6 December 2013

Types of Sorting Algorithms.

Selection Sort
The selection sort, makes only only exchange for every pass through the list. In order to do this, a selection sort looks for the largest value as it makes a pass and, after completing the pass, places it in the last location.

Quick Sort
Basically, we partition the list into two, based on the pivot(which is always the one on the front of the list, L[0] in our case), on one side we put things greater than the pivot and on the other less than the pivot. Than, we perform the recursion of itself, on both sides to keep partitioning. and putting things into order, in the end, we merge them.

Merge Sort 
The online reading states that, "Merge sort is a recursive algorithm that continually splits a list in half. If the list is empty or has one item, it is sorted by definition (the base case). If the list has more than one item, we split the list and recursively invoke a merge sort on both halves. Once the two halves are sorted, the fundamental operation, called a merge, is performed". This in short in lecture is clarified such that, divide the list in half, (merge) sort the halves, then merge the sorted results. We use a helper function merge, to put it in order, as well as connect them together.

No comments:

Post a Comment