WRITELOOP

GROKKING ALGORITHMS - SELECTION SORT

2022 April 19
  • Selection sort is an algorithm that can be used when you have to order elements based on some criteria. You have a list of unordered elements, and you build a new list where you put each element in ascending or descending order, one at a time, until every element on the unordered list is on the new sorted list.

  • Since you have an unordered list with n elements, and you pass at each one of them n number of times, the Big O notation for this algorithm is: O₍n x n), which is equal to O₍n²₎ .

  • When you are passing through the unordered array, each time you add an element into the ordered array the number of elements decrease. Even then, there is no n * 1/2n , since Big O notation only works with integer numbers.

  • “Quicksort” is a faster sorting algorithm.

NOTE: The original content(s) that inspired this one can be found at:
https://www.amazon.com/Grokking-Algorithms-illustrated-programmers-curious/dp/1617292230
All copyright and intellectual property of each one belongs to its' original author.