Please enable JavaScript to use CodeHS

CodeHS Glossary


Insertion Sort General

Sorting algorithm that sorts an array of values. The idea behind insertion sort is to have a sorted part of the list and an unsorted part. On each iteration of the algorithm, we grab the next unsorted element and place it in its proper position in the sorted section. Big-Oh complexity of O(n^2) In the best case scenario, when the list passed in is already sorted, this algorithm runs in O(n), since no insertions need to be made. On average, the complexity will be O(n^2)