# Types of Sorting Algorithms

Bubble Sort

Bubble sort is a simple sorting algorithm. This sorting algorithm is comparison-based algorithm in which each pair of adjacent elements is compared and the elements are swapped if they are not in order. This algorithm is not suitable for large data sets as its average and worst case complexity are of Ο(n 2) where n is the number of items.

Comparable Elements

View Homework Help - sorting-algorithms from CS 241 at Cal Poly Pomona. Sorting Algorithms Selection Sort Input: list of n comparable elements indexed 0 to n-1 Output: list of elements sorted in

Heapsort

Heapsort can be thought of as an improved selection sort: like that algorithm, it divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element and moving that to the sorted region.

Heapsort Worst Case: O(NlogN)

Since big-O notation ignores constants, though, this isn't reflected in the best-case and worst-case analysis. quick sort- This one I don't know for sure. I'm not sure what the best case and worst case situations are for this.

Insertion Sort Algorithm

Hence the name, insertion sort. The array is searched sequentially and unsorted items are moved and inserted into the sorted sub-list (in the same array). This algorithm is not suitable for large data sets as its average and worst case complexity are of Ο(n 2), where n is the number of items.

Merge Sort

Merge sort is a sorting technique based on divide and conquer technique. With worst-case time complexity being Ο(n log n), it is one of the most respected algorithms. Merge sort first divides the array into equal halves and then combines them in a sorted manner.

Mergesort Code Methods: Mergesort (2), Merge

Quicksort

Quick sort is a highly efficient sorting algorithm and is based on partitioning of array of data into smaller arrays. A large array is partitioned into two arrays one of which holds values smaller than the specified value, say pivot, based on which the partition is made and another array holds values greater than the pivot value.

image: algolist.net
Quicksort Code Methods: Quicksort (2), Median3

Quicksort is at one end of the spectrum of divide-and-conquer algorithms, with merge sort at the opposite end. Quicksort is a conquer-then-divide algorithm, which does most of the work during the partitioning and the recursive calls.

Selection Sort Array to be Sorted: A

Comparison to other sorting algorithms. Among simple average-case Θ(n 2) algorithms, selection sort almost always outperforms bubble sort and gnome sort. Insertion sort is very similar in that after the kth iteration, the first k elements in the array are in sorted order.

Shellsort Invented by Donald Shell

Shell Sort is a generalized version of insertion sort.It is an in–place comparison sort. Shell Sort is also known as diminishing increment sort, it is one of the oldest sorting algorithms invented by Donald L. Shell (1959.). This algorithm uses insertion sort on the large interval of elements to sort.

source: codingeek.com