Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wikipedia's insertion sort pseudo code is difficult to parse mentally for normal people:
- for i = 1 to length(A)
- j ← i
- while j > 0 and A[j-1] > A[j]
- swap A[j] and A[j-1]
- j ← j - 1
- end while
- end for
- I think I came up with the easiest version of the sorting algorithm for people to parse mentally…. using my flowcharts… I took if form this pseudocode http://pastebin.com/VxKxZW5r , but I reworded the while condition to to SECOND > 0 AND A[FIRST] > A[SECOND] where FIRST=POS and SECOND=POS+1. then I did swap(FIRST,SECOND)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement