Monday, February 13, 2012

case STUDY6












    BUBBLE SORT

           Also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order.       The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, 



SELECTION SORT 

            is a sorting algorithm, specifically an in-place comparison sort.
It has O(n2) time complexity, making it inefficient on large lists, 
and generally performs worse than the similar insertion sort.
Selection sort is noted for its simplicity,
and also has performance advantages over more complicated 
algorithms in certain situations, particularly where auxiliary memory is limited  
Selection Sort Animation





















SHELL SORT

              also known as Shell sort or Shell's method is an in-place
It generalizes an exchanging sort, such as insertion or bubble sort,
by allowing the comparison and exchange of elements that lie far apart.  

Step-by-step visualisation of Shellsort       



BUCKET SORT
            or bin sort, is a sorting algorithm that works by partitioning
an array into a number of buckets. Each bucket is then sorted
individually, either using a different sorting algorithm,
or by recursively applying the bucket sorting algorithm.



Elements are distributed among bins

Elements are distributed among bins



MERGE SORT
   
           Most implementations produce a stable sort,
which means that the implementation preserves
the input order of equal elements in the sorted output.

Merge-sort-example-300px.gif














An example of merge sort.
First divide the list into the smallest unit
(1 element), then compare each element
with the adjacent list to sort and merge
the two adjacent list. Finally all the
lements are sorted and merged.




QUICK SORT

        is a sorting algorithm developed by Tony  Hoare. that,
on average, makes . comparisons to sort n items.
In the worst case, it makes O(n2) comparisons, 
though this behavior is rare. Quick sort is often
faster in practice than other O(nlog n) algorithms.
Additionally, quick sort's sequential and localized memory 
references work well with a cache. Quick sort can be
so the entire sort can be done with only O(log n) additional space.

Quicksort in action on a list of numbers. The horizontal lines are pivot values.