DSA - Sorting - Selection Sort

Introduction The selection sort is an in-place comparison sorting algorithm. It’s similar to bubble sort in that it works by repeatedly swapping items in a list and not very efficient on larger lists. source Code Example func selectionSort(_ array: [Int]) -> [Int] { var A = array let N = array.count for i in 0 ..< N { var jMin = i for j in (i + 1) ..< N { if A[j] < A[jMin] { jMin = j } } if jMin !...

October 23, 2024 · 1 min · Dmytro Chumakov