Saturday, 15 October 2011

Sorting Algorithm Handy Guide

Analysis of Sorting Algorithms:


STABILITY: Ability to maintain the relative Ordering(Duplicates in Data) of the input Data.
IN PLACE: Ability to perform the algorithm on the input data Memory, Not using extra Memory.
Time Complexity.

Sorting
STABILITY
IN PLACE
TIME COMPLEXITY
Best Case
Average Case
Worst Case
Insertion Sort
Yes
Yes
O(n)
O(n^2)
O(n^2)
Bubble Sort
Yes
Yes
O(n)
O(n^2)
O(n^2)
Selection Sort
Yes
Yes
O(n^2)
O(n^2)
O(n^2)
Quick  Sort
NO
Yes
O(nlogn)
O(nlogn)
O(n^2)
Merge Sort
YES
NO
O(nlogn)
O(nlogn)
O(nlogn)
Heap Sort
NO
NO
O(nlogn)
O(nlogn)
O(nlogn)

No comments:

Post a Comment