Selection Sorting Technique in Data Structure Using C

Published: 22 March 2021
on channel: Ashoksinh Zala Academy
23
3

Sorting is an arrangement of data items in a sequential order according to an ordering criterion means ascending or descending order. Many sorting technique like selection sort, bubble sort, insertion sort, quick sort, bucket sort, merge sort and shell sorting. The selection sort is the simplest method of sorting. The selection sort is faster than bubble sort. The selection sort works by 0th element is compared with all other elements. If 0th element is found to be greater than the compared element then they are interchanged, continue this process to find first smallest element at the first element to list. So after the first iteration the smallest element is placed at the 0th position. The same procedure is repeated for the 1st element and continues this process until you can find whole list as sorting in ascending or descending order. Assume that an array x content five elements. The selection sort algorithm works as follows way :
1. In the first iteration the 0th element 5 is compared with 1st element 3 and since 5 is greater than 3, they are interchanged.
2. Now the 0th element 3 is compared with 2nd element 6. But 3 being less than 6, hence they are not interchanged.
3. Now the 0th element 3 is compared with 3rd element 2 and since 3 is grater than 2, they are interchanged.
4. This process is repeated till 0th element is compared with rest of the elements. During the comparison if 0th element is found to be greater than then the compared element, then they are swapping, otherwise not.
5. At the end of the first iteration, the 0th element holds the smallest element.
6. This process is repeated with the 1st element 5 and so on.
7. So if there are n elements, then after (n-1) iterations the array is sorted.
Advantages of Selection sort are as follow:
1. It is simple sorting technique.
2. It is easy to implement.
3. First iteration table we find first smaller value at first element.
Disadvantage of Selection sort are as follow:
1. Large list not handing by this sorting technique.
2. It is very inefficient sorting technique.


On this page of the site you can watch the video online Selection Sorting Technique in Data Structure Using C with a duration of hours minute second in good quality, which was uploaded by the user Ashoksinh Zala Academy 22 March 2021, share the link with friends and acquaintances, this video has already been watched 23 times on youtube and it was liked by 3 viewers. Enjoy your viewing!