-
-
Save hakee/2001448 to your computer and use it in GitHub Desktop.
Insertion Sort pseudocode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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