Created
September 29, 2016 16:28
-
-
Save drnickallgood/d637edf180fd022e72446eaeddd16fa3 to your computer and use it in GitHub Desktop.
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
[ 115, 20, 99, 200, 59] | |
inspect and store pos 1 in list (20) | |
is pos-1 > stored? | |
yes | |
move 115 over one spot to pos1 | |
[ 115, 115, 99, 200, 59] [ 20] | |
counter is pos - 2 | |
is value at counter > value at pos ? no | |
insert here | |
[ 20, 115, 99, 200, 59] [ 20 ] | |
increment position to 2 | |
inspect and store 99 in temp [99] | |
counter = pos - 1 | |
counter > temp? yes | |
pos value = counter value | |
[20, 115, 115, 200, 59] | |
position still 2 | |
counter = pos -2 | |
counter pointing at 20 | |
counter > temp? no | |
insert in position 1 | |
[20,99,115,200,59] | |
increment position to 3, pointing at 200 | |
store position 3 into temp | |
compare position -1 to temp (115 > 200? ) no | |
compare position -2 to temp (99 > 200? ) no | |
compare position -3 to temp (20 > 200?) no | |
increment position to 4, pointing at 59 | |
store 59 in temp | |
compare position-1 > temp (200 > temp) ? yes | |
move position -1 over to position | |
[20, 99, 115, 200, 200] | |
compare position-2 > temp (115 > 59) ? yes | |
move position -2 to position -1 | |
[20, 99, 115, 115, 200] | |
compare position -3 > temp (99 > 59? ) yes | |
move position -3 to position -2 | |
[20,99, 99, 115, 200] | |
compare position -4 > temp (20 > 59? ) no | |
compare position -5 > temp ? invalid , back up a step and insert | |
in position -4 | |
[20,59,99,115,200] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment