Created
April 21, 2015 09:37
-
-
Save dragstar328/d3fd60736e2f049b1126 to your computer and use it in GitHub Desktop.
アルゴリズムクイックリファレンス:挿入ソート
This file contains hidden or 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
def insertion_sort(target): | |
for i in range(len(target)): | |
insert(target, i, target[i]) | |
def insert(target, pos, value): | |
i = pos - 1 | |
while (i >= 0 and target[i] > value): | |
target[i + 1] = target[i] | |
i = i - 1 | |
target[i + 1] = value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment