Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7d7ab4f

Browse files
Merge pull request fnplus#343 from Aditya2603/patch-6
[Algorithm] Insertion Sort [Python]
2 parents 4cccb71 + 0661561 commit 7d7ab4f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
arr = [5,14,18,6,21]
2+
n= len(arr)
3+
i = 1
4+
while (i<=n-1):
5+
value = arr[i]
6+
position = i
7+
8+
while (position>0 and arr[position-1]>value):
9+
arr[position] = arr[position-1]
10+
position = position -1
11+
12+
i = i+1
13+
arr[position] = value
14+
15+
16+
for i in arr:
17+
print i,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /