Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,8 +1,13 @@
|
|||
{{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.
|
||||
{{omit from|GUISS}}
|
||||
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.
|
||||
|
||||
Although insertion sort is an <span style="font-family: serif">[[O]](''n''<sup>2</sup>)</span> algorithm, its simplicity, low overhead, good locality of reference and efficiency make it a good choice in two cases (i) small <span style="font-family: serif">''n''</span>, (ii) as the final finishing-off algorithm for <span style="font-family: serif">[[O]](''n'' log''n'')</span> algorithms such as [[Merge sort|mergesort]] and [[quicksort]].
|
||||
Although insertion sort is an <span style="font-family: serif">[[O]](''n''<sup>2</sup>)</span> algorithm, its simplicity, low overhead, good locality of reference and efficiency make it a good choice in two cases: <br>
|
||||
(i) small <span style="font-family: serif">''n''</span>, <br>
|
||||
(ii) as the final finishing-off algorithm for <span style="font-family: serif">[[O]](''n'' log''n'')</span> algorithms such as [[Merge sort|mergesort]] and [[quicksort]].
|
||||
|
||||
The algorithm is as follows (from [[wp:Insertion_sort#Algorithm|wikipedia]]):
|
||||
'''function''' ''insertionSort''(array A)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue