Skip to content

Instantly share code, notes, and snippets.

@olupotd
Created December 5, 2013 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olupotd/7806196 to your computer and use it in GitHub Desktop.
Save olupotd/7806196 to your computer and use it in GitHub Desktop.
Insertion Sort in Brief
Here's the algorithm for this type of sort. please implement it also
so that you can learn. Thanks.
function insertionSort(array A)
for i from 1 to length[A]-1 do
value := A[i]
j := i-1
while j >= 0 and A[j] > value do
A[j+1] := A[j]
j := j-1
done
A[j+1] = value
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment