Quidest?

selection sort algorithm

· Lorenzo Drumond

It’s similar to bubble sort in that it works by repeatedly swapping items in a list. However, it’s slightly more efficient than bubble sort because it only makes one swap per iteration.

Pseudocode

  1. For each index:
  2. Set smallest_idx to the current index
  3. For each index from smallest_idx+1 to the end of the list: 1. If the number at the inner index is smaller than the number at smallest_idx, set smallest_idx to the inner index
  4. Swap the number at the current index with the number at smallest_idx

References

#computer_science #algorithm #notation #sorting #binary_search #programming #boot_dev #big_o