Sorting algorithms/Insertion sort: Difference between revisions

Content added Content deleted
m (Mark as using wikipedia content (the algorithm description))
Line 1: Line 1:
{{task|Sorting Algorithms}}
{{task|Sorting Algorithms}}
{{Sorting Algorithm}}
{{Sorting Algorithm}}
{{wikipedia|Insertion sort}}
An <span style="font-family: serif">[[O]](''n''<sup>2</sup>)</span> sorting algorithm which moves elements one at a time into the correct position. The algorithm consists of inserting one element at a time into the previously sorted part of the array, moving higher ranked elements up as necessary. To start off, the first (or smallest, or any arbitrary) element of the unsorted array is considered to be the sorted part.
An <span style="font-family: serif">[[O]](''n''<sup>2</sup>)</span> sorting algorithm which moves elements one at a time into the correct position. The algorithm consists of inserting one element at a time into the previously sorted part of the array, moving higher ranked elements up as necessary. To start off, the first (or smallest, or any arbitrary) element of the unsorted array is considered to be the sorted part.