Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created January 19, 2012 19:51
Show Gist options
  • Save thinkphp/1642162 to your computer and use it in GitHub Desktop.
Save thinkphp/1642162 to your computer and use it in GitHub Desktop.
Insertion Sort pseudocode
/*
Pseudocode of the complete algorithm
Twitter : http://twitter.com/thinkphp
Website : http://thinkphp.ro
Google Plus : http://gplus.to/thinkphp
MIT Style License
*/
INSERTION-SORT(V)
for i<-2 to length(V)
do key <- V[i]
=>INSERT V[i] into the sorted sequence V[1..i-1]
j <- i - 1
while j>=0 and V[j] > key
V[j+1] <- V[j]
V[j+1] <- key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment