# Bubble Sort Bubble sort is a simple sorting algorithm.

It 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, it is a comparison sort. Worst case performance О(n²) Best case performance О(n²) Average case performance О(n²) Selection Sort 1. Find the minimum value in the list 2. Swap it with the value in the first position 3. Repeat the steps above for the remainder of the list (starting at the second position and advancing each time) Worst case performance О(n²) Best case performance О(n²) Average case performance О(n²) Insertion Sort If the first few objects are already sorted, an unsorted object can be inserted in the sorted set in proper place. This is called insertion sort. An algorithm consider the elements one at a time, inserting each in its suitable place among those already considered (keeping them sorted). Worst case performance О(n2) Best case performance O(n) Average case performance О(n2) Quick Sort Quicksort sorts by employing a divide and conquer strategy to divide a list into two sublists. The steps are: 1. Pick an element, called a pivot, from the list. 2. Reorder the list so that all elements which are less than the pivot come before the pivot and so that all elements greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation. Recursively sort the sub-list of lesser elements and the sub-list of greater elements. Worst case performance Θ(n2) Best case performance Θ(nlogn) Average case performance Θ(nlogn)

and deallocate them (or allow them to be garbage collected) when no longer needed A balanced. Here. where k is a constant. 6. by comparing individual digits sharing the same significant position. 0. but because integers can represent strings of characters (e. mergesort(a. radix sort is a sorting algorithm that sorts integers by processing individual digits. 3. In the example you have taken there are only 5 elements and is very easy to simulate Worst case performance Θ(nlogn) Best case performance Θ(nlogn) Average case performance Θ(nlogn) RADIX SORT:In computer science. A positional notation is required. such that the key in the element at position k in the list is at least as large as the key in the element at position 2k and 2k + 1 if exist.HEAP SORT:Heapsort complexity is always O(n log n) Quicksort is usually O(n log n) but in the worst case slows to O(n2) Quicksort is generally faster.. 4) merge(a. So. names or dates) and specially formatted floating point numbers. 4) mid = 0 + 4 / 2 = 2 mergesort(a. 8} low = 0.g. 2) So. Then this element will be merged with the next one and both will be put in correct order and since this is a recursive function. but Heapsort is better in time-critical applicationsHEAP SORT:Definitions of heap: A large area of memory from which the programmer can allocate blocks as needed. 2. here is the sequence of calls: a[] = {3. 4. Worst case performance Θ(nlogn) Best case performance Θ(nlogn) Average case performance Θ(nlogn) MERGE SORT:MergeSort uses divide & conquer strategy to sort the elements. 2) mergesort(a. it will be repeated till you complete the merge and come out. complexity of radix sort is O(k*N). this goes on till: (low < high) is satisfied. 0. left-justified binary tree in which no node has a value greater than the value in its parent. you go on dividing till only one element is left. A heap is a list in which each element contains a key. 0. . radix sort is not limited to integers Two classifications of radix sorts are least significant digit (LSD) radix sorts and most significant digit (MSD) radix sorts. high = 4. 5. each of the mergesort() calls will again go back and call mergesort() and merge().