Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

18c. Data Structure and Algorithms Selection Sort

Selection sort is a simple in-place comparison-based sorting algorithm that divides a list into a sorted and an unsorted part. It repeatedly selects the smallest element from the unsorted part and swaps it with the leftmost unsorted element, gradually building the sorted part. The algorithm has a time complexity of O(n²), making it inefficient for large data sets.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

18c. Data Structure and Algorithms Selection Sort

Selection sort is a simple in-place comparison-based sorting algorithm that divides a list into a sorted and an unsorted part. It repeatedly selects the smallest element from the unsorted part and swaps it with the leftmost unsorted element, gradually building the sorted part. The algorithm has a time complexity of O(n²), making it inefficient for large data sets.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Data Structure and

Algorithms Selection
Sort
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.
Algorithm
Step 1 − Set MIN to location 0
Step 2 − Search the minimum element in the list
Step 3 − Swap with value at location MIN
Step 4 − Increment MIN to point to next element
Step 5 − Repeat until list is sorted

You might also like