Skip to content

Files

Failed to load latest commit information.

Latest commit

322eaa6 · Apr 29, 2017

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Insertion Sort

Insertion sort does exactly what you would expect: it inserts each element of the array into its proper position, leaving progressively larger stretches of the array sorted. What this means in practice is that the sort iterates down an array, and the part of the array already covered is in order; then, the current element of the array is inserted into the proper position at the head of the array, and the rest of the elements are moved down, using the space just vacated by the element inserted as the final space.

Insertion Sort

A visualization on Insertion Sort

Insertion sort demonstration

Complexity Analysis

  • Worst Case - О(n2)
  • Average Case - О(n2)
  • Best Case - O(n)

More on this topic