Source Code: https://www.instms.com/data-structure...
In today video lecture we will learn about the second simplest sorting algorithm that is called selection sort. Selection sort algorithm is also used where the data set is small. It is not suitable for large size data set because many comparison and swaps are required to sort the given data. In data structures selection sort is also important to understand because it is simple and can provide idea about flow of sorting algorithms. In this video session we will learn the following concepts.
1. Selection Sort Algorithm
2. Selection Sort Animation
3. Selection Sort Steps
4. Selection Sort Time Complexity
5. Selection Sort Space Complexity
We here also get help of an animation for better understanding of steps that are necessary to selection sort for sorting out the provided data set. In selection sort the array is divided into two sub arrays these are sorted and unsorted arrays. The values from unsorted array are picked up one after another and compared in each pass and if these values to find out the next suitable value from unsorted part to put in sorted part. When any comparison is successful than these values are swapped.In this implementation swap using third variable named as temp is used. The worst case of selection sort required n square comparisons but only n swaps. That is why this algorithm is much suitable from bubble sort.