Fiveable
Fiveable

Selection Sort

Definition

Selection Sort is a simple sorting algorithm that repeatedly finds the minimum element from an unsorted portion of the list and swaps it with the first element of that portion until the entire list is sorted.

Analogy

Imagine you have a deck of cards and you want to sort them in ascending order. With selection sort, you would repeatedly find the smallest card from the remaining unsorted cards and swap it with the first card in that portion. This process continues until all cards are sorted.

Related terms

Insertion Sort: A sorting algorithm where elements are gradually inserted into their correct positions within a partially sorted array.

Bubble Sort: A simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.

Quick Sort: A divide-and-conquer sorting algorithm that selects a pivot element and partitions the array around it. It recursively sorts subarrays before and after the pivot.

"Selection Sort" appears in:

Practice Questions (4)

  • What is the time complexity of selection sort and insertion sort in the worst case scenario?
  • Which sorting algorithm is simpler: selection sort or insertion sort?
  • How does selection sort work?
  • What is one advantage of insertion sort over selection sort?


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.