This document discusses various sorting algorithms including insertion sort, merge sort, quick sort, and selection sort. It provides flow charts and source code examples for each algorithm. It also outlines some key applications of each sorting algorithm, such as insertion sort being useful for small data sets and quick sort being cache-friendly. Merge sort can help solve inversion count problems and is used for external sorting of large data sets.
This document discusses various sorting algorithms including insertion sort, merge sort, quick sort, and selection sort. It provides flow charts and source code examples for each algorithm. It also outlines some key applications of each sorting algorithm, such as insertion sort being useful for small data sets and quick sort being cache-friendly. Merge sort can help solve inversion count problems and is used for external sorting of large data sets.
This document discusses various sorting algorithms including insertion sort, merge sort, quick sort, and selection sort. It provides flow charts and source code examples for each algorithm. It also outlines some key applications of each sorting algorithm, such as insertion sort being useful for small data sets and quick sort being cache-friendly. Merge sort can help solve inversion count problems and is used for external sorting of large data sets.
INTRODUCTION Data Structure Used Flow chart of algorithms Insertion sort Merge sort Quick sort Selection sort Source code Description of code 1.Insertion Sort Lorem ipsum 2.Merge sort Merge sort Description of code Description of code - Merge sort Quick sort Quick sort Description of code Lorem ipsum 4.Selection sort Description of code Description of code Selection sort Implementation using Javascript Applications of sorting algorithms 1.Selection sort: • Selection sort almost always outperforms bubble sort and gnome sort. • Can be useful when memory write is a costly operation. • While selection sort is preferable to insertion sort in terms of number of writes (Θ(n) swaps versus Ο(n^2) swaps). • It almost always far exceeds the number of writes that cycle sort makes, as cycle sort is theoretically optimal in the number of writes. • This can be important if writes are significantly more expensive than reads, such as with EEPROM or Flash memory, where every write lessens the lifespan of the memory. 2.Quick sort • Quicksort is a cache-friendly algorithm as it has a good locality of reference when used for arrays. • It is an in-place sort that does not require any extra storage memory. • Numerical computations and in scientific research, for accuracy in calculations most of the efficiently developed algorithm uses priority queue and quick sort is used for sorting. • The sorting algorithm is used for information searching and as Quicksort is the fastest algorithm so it is widely used as a better way of searching. • Sports scores are quickly organised using quick sort algorithm. 3.Merge sort • Inversion count problem: • Merge sort helps to solve this problem by telling the number of inversion pairs in an unsorted array. The inversion count problem tells how many pairs need to be swapped in order to get a sorted array. • External sorting: • Merge sort is an external sorting technique. Databases use this technique to sort sets of data that are too large to be loaded into the memory 4.Insertion sort • Insertion sort is more efficient in practice on small arrays than asymptotically fast algorithms like Quicksort and Heap Sort, because of better constant. • Insertion sort can also be implemented when tailors arrange shirts in a cupboard, they always keep them in sorted order of size and thus insert new shirts at the right position very quickly by moving other shirts forward to keep the right place for a new shirt. • While shopping on flipkart or amazon, you sort items based on your choice, that is, price low to high or high to low. • The contact list in your phone is sorted, which means you can easily access your desired contact from your phone since the data is arranged in that manner for you. In other words, “it is sorted”.