Notes

Source: 📖 Problem Solving with Algorithms and Data Structures using Python 6.8

Date: 2021-11-04


Selection sort runtime function

A selection sort, like a bubble sort, iterates through the \(n\) items in the collection it's sorting \(n-1\) times, so these nested loops give it a runtime function of \(O(n^2)\). However, a selection sort doesn't need to perform as many swaps as a bubble sort, meaning that it actually runs considerably faster than a bubble sort in most cases.


See also: