#SelectionSort
Shakersort, Heapsort
Radixsort, Selectionsort

Die sind alle weniger interessant. Radix ist und bleibt ein Hexenwerk...
September 3, 2026 at 5:01 PM
Sorting Algorithm: Selection
Selection sort makes sure that it selects the smallest (or largest, depending on the implementation) element from the unsorted portion of the array and moves it to its correct position from the start of the array. SelectionSort(arr, n): for i from 0 to n-2: // i loops over each element except the last minElemIdx = i // let first element of the unsorted part is the smallest for j from i+1 to n-1: // j loops through out the unsorted part, to get minimum value index of this part if arr[j] < arr[minElemIdx]: minElemIdx = j Swap arr[i] and arr[minElemIdx] // smallest element at its correct position lets take an example array to do dry-run for selection sort(ascending order): array has values -2, 4, -6, -5, 1 so array after selection sort, would be -6, -5, -2, 1, 4 _1st outer loop_ i = 0 minElemIdx = i = 0 1st inner loop j = i + 1 -> 0 + 1 -> 1 4 < -2 (false) j = 2 -6 < -2 (true) minElemIdx = 2 j = 3 -5 < -6 (false) j = 4 1 < -6 (false) 1st inner loop completed Swap -2 (arr[0]) and -6(arr[minElemIdx]) -6 4 -2 -5 1 _1st outer loop completed_ If you observe here, our first element is the least element in the array Now on to the second _2nd outer loop_ i = 1 minElemIdx = i = 1 2nd inner loop j = i + 1 = 2 -2 < 4 (true) minElemIdx = 2 j = 3 -5 < -2 (true) minElemIdx = 3 j = 4 4 < 1 (false) 2nd inner loop completed Swap 4 (arr[1]) and -6 (arr[minElemIdx]) -6 -5 -2 4 1 _2nd outer loop completed_ _3rd outer loop_ i = 2 minElemIdx = i = 2 3rd inner loop j = i + 1 = 3 4 < -2 (false) j = 4 1 < -2 (false) 3rd inner loop completed Swap won't happen as minElemIdx is same as i -6 -5 -2 4 1 _3rd outer loop completed_ _4th outer loop_ i = 3 minElemidx = i = 3 4th inner loop j = i + 1 = 4 1 < 4 (true) minElemIdx = 4 4th inner loop completed Swap 4(arr[3]) and 1(arr[minElemIdx]) -6 -5 -2 1 4 _4th outer loop completed_ We reached the sorted output using selection sort algorithm This is one of the many in-place sorting algorithms with space complexity is O(1)(i.e.) it doesn't need an extra space to perform this. This takes less memory writes during the sorting algorithm(next to cycle sort) Flip side or a major drawback with this sorting algorithm is that the time complexity is O(n^2) (Inner loop O(n) * Outer loop O(n))
forem.com
March 13, 2025 at 6:13 PM
Solved ICS 141 – 02 Lab 9: Sorting

Part 1. Sorting an array of integers In this part of the lab, you will use test the selection sort method and, then, you will modify the method to sort in descending order. 1- To start, create a new Java class in your project, called SortingDriver, that includes…
Solved ICS 141 – 02 Lab 9: Sorting
Part 1. Sorting an array of integers In this part of the lab, you will use test the selection sort method and, then, you will modify the method to sort in descending order. 1- To start, create a new Java class in your project, called SortingDriver, that includes the main method. 2- Copy the selectionSort method from the lecture12 slides and paste it inside SortingDriver.
jarviscodinghub.com
October 21, 2025 at 12:36 PM
interesting #scala #jvm fp oo first vs #fsharp #dotnet fp with oo but fp first and ML lang > for this user and in his conditions, quicksort takes 2 orders of magnitude more in scala (15s) than F# (0.9s) users.scala-lang.org/t/selections...
Selectionsort , time scala vs F#
I’ve written a selection sort of 10 integers in scala and F#. scala “sbt run” takes 15 seconds. F# “dotnet run” takes 0.9 seconds. How can i improve this speed. Can i create a self-contained assem...
users.scala-lang.org
December 17, 2024 at 2:52 PM
CS 202 Homework 1 – Algorithm Efficiency and Sorting

Question 1 – 15 points Create a main.cpp file which does the following in order: creates an array from the following: {12, 7, 11, 18, 19, 9, 6, 14, 21, 3, 17, 20, 5, 12, 14, 8}. calls the selectionSort function, displays the number of key…
CS 202 Homework 1 – Algorithm Efficiency and Sorting
Question 1 – 15 points Create a main.cpp file which does the following in order: creates an array from the following: {12, 7, 11, 18, 19, 9, 6, 14, 21, 3, 17, 20, 5, 12, 14, 8}. calls the selectionSort function, displays the number of key comparisons and the number of data moves to sort this array, and calls the displayArray function to show the contents of the array after selection sorting&hellip;
programming.engineering
April 23, 2025 at 1:43 PM
CS 202 Homework 1 – Algorithm Efficiency and Sorting

Question 1 – 15 points Create a main.cpp file which does the following in order: creates an array from the following: {12, 7, 11, 18, 19, 9, 6, 14, 21, 3, 17, 20, 5, 12, 14, 8}. calls the selectionSort function, displays the number of key…
CS 202 Homework 1 – Algorithm Efficiency and Sorting
Question 1 – 15 points Create a main.cpp file which does the following in order: creates an array from the following: {12, 7, 11, 18, 19, 9, 6, 14, 21, 3, 17, 20, 5, 12, 14, 8}. calls the selectionSort function, displays the number of key comparisons and the number of data moves to sort this array, and calls the displayArray function to show the contents of the array after selection sorting&hellip;
programming.engineering
February 17, 2025 at 1:25 PM
Sorting Algorithm: Selection
Selection sort makes sure that it selects the smallest (or largest, depending on the implementation) element from the unsorted portion of the array and moves it to its correct position from the start of the array. SelectionSort(arr, n): for i from 0 to n-2: // i loops over each element except the last minElemIdx = i // let first element of the unsorted part is the smallest for j from i+1 to n-1: // j loops through out the unsorted part, to get minimum value index of this part if arr[j] < arr[minElemIdx]: minElemIdx = j Swap arr[i] and arr[minElemIdx] // smallest element at its correct position lets take an example array to do dry-run for selection sort(ascending order): array has values -2, 4, -6, -5, 1 so array after selection sort, would be -6, -5, -2, 1, 4 _1st outer loop_ i = 0 minElemIdx = i = 0 1st inner loop j = i + 1 -> 0 + 1 -> 1 4 < -2 (false) j = 2 -6 < -2 (true) minElemIdx = 2 j = 3 -5 < -6 (false) j = 4 1 < -6 (false) 1st inner loop completed Swap -2 (arr[0]) and -6(arr[minElemIdx]) -6 4 -2 -5 1 _1st outer loop completed_ If you observe here, our first element is the least element in the array Now on to the second _2nd outer loop_ i = 1 minElemIdx = i = 1 2nd inner loop j = i + 1 = 2 -2 < 4 (true) minElemIdx = 2 j = 3 -5 < -2 (true) minElemIdx = 3 j = 4 4 < 1 (false) 2nd inner loop completed Swap 4 (arr[1]) and -6 (arr[minElemIdx]) -6 -5 -2 4 1 _2nd outer loop completed_ _3rd outer loop_ i = 2 minElemIdx = i = 2 3rd inner loop j = i + 1 = 3 4 < -2 (false) j = 4 1 < -2 (false) 3rd inner loop completed Swap won't happen as minElemIdx is same as i -6 -5 -2 4 1 _3rd outer loop completed_ _4th outer loop_ i = 3 minElemidx = i = 3 4th inner loop j = i + 1 = 4 1 < 4 (true) minElemIdx = 4 4th inner loop completed Swap 4(arr[3]) and 1(arr[minElemIdx]) -6 -5 -2 1 4 _4th outer loop completed_ We reached the sorted output using selection sort algorithm This is one of the many in-place sorting algorithms with space complexity is O(1)(i.e.) it doesn't need an extra space to perform this. This takes less memory writes during the sorting algorithm(next to cycle sort) Flip side or a major drawback with this sorting algorithm is that the time complexity is O(n^2) (Inner loop O(n) * Outer loop O(n))
dev.to
March 13, 2025 at 6:17 PM