Data Structures: Selection Sort
Data Structures: Selection Sort
Home / My courses / BCA204A21T / Unit 2 - SEARCHING & SORTING -Selection Sort / SELECTION SORT
SELECTION SORT
Definition
Example
Algorithm
Selection sort is a simple sorting algorithm. This sorting algorithm is an in-place comparison-based algorithm in which the list is divided into two parts, the sorted part at
the left end and the unsorted part at the right end. Initially, the sorted part is empty and the unsorted part is the entire list.
The smallest element is selected from the unsorted array and swapped with the leftmost element, and that element becomes a part of the sorted array. This process
continues moving unsorted array boundary by one element to the right.
This algorithm is not suitable for large data sets as its average and worst case complexities are of Ο(n2), where n is the number of items.
Example
SELECTION SORT
Definition
Example
Algorithm
Algorithm
for i = 1 to n - 1
min = j;
end if
end if
end for
end procedure
Challenging Questions
◄ QUICK SORT Jump to... Selection Sort Demo ►
Data Structures
Home / My courses / BCA204A21T / Unit 2 - SEARCHING & SORTING -Selection Sort / SELECTION SORT
SELECTION SORT
Definition
Example
Algorithm
Step 1: Find the smallest element. Compare the smallest element 11 with the first element in the array 64.
Step 2: Start scanning the entire list, and find the next least element i.e 12. It is compared the element in the second position 25. Compare and swap it
Step 3: Start scanning the entire list, and find the next least element i.e 22. It is compared the element in the third position 25. Compare and swap it