Skip to content
← Back to glossary

選択ソートSelection sort

Learn in the textbookSearch and Sorting Algorithms

DefinitionSelection sort (選択ソート) repeatedly picks the smallest value (or the largest) from the part not yet sorted and swaps it with the value at one end of that part.

ExplanationSorting means rearranging data in order of value. One round that scans the unsorted range and fixes the value at one end is called a pass, and each pass shrinks the range by one. The number of comparisons grows roughly with the square of the number of items, so large data sets take a long time.

AnalogyIt is like tidying a hand of cards: find the lowest card among those not yet arranged, place it just to the right of the arranged ones, and repeat.

Memory hookSelection means picking out: like choosing a team captain, you compare everyone first and then pick one.

Related past-exam questions(2 questions)