Selection Sort Algorithm in Data Structure using C Language | BCA SEM 2 BKNMU Junagadh

 
In selection sort, the smallest value among the unsorted elements of the array is selected in every pass and inserted to its appropriate position into the array. It is also the simplest algorithm. It is an in-place comparison sorting algorithm. In this algorithm, the array is divided into two parts, first is sorted part, and another one is the unsorted part. Initially, the sorted part of the array is empty, and unsorted part is the given array. Sorted part is placed at the left, while the unsorted part is placed at the right.
In selection sort, the first smallest element is selected from the unsorted array and placed at the first position. After that second smallest element is selected and placed in the second position. The process continues until the array is entirely sorted.
algorithm:-
Start with the First Element: Begin with the first element in the list.
Find the Smallest Element: Go through the rest of the list to find the smallest element.
Swap with First Element: Once you find the smallest element, swap it with the first element.
Move to the Next Element: Now, move on to the second element in the list.
Repeat Steps 2-4: Repeat steps 2 to 4 for the remaining unsorted elements in the list, always starting from the next element after the one you just sorted.
Continue Until Sorted: Keep repeating these steps until the entire list is sorted.
Example :
https://drive.google.com/file/d/1ohbY...


Instagram
 
 / bca.school  
Facebook
 
 / bcaschooll  
Website
https://bcaschool.blogspot.com/


Post a Comment

Thanks for comment.

Previous Post Next Post