Skip to content

Commit 5e3a0d4

Browse files
committed
insertion sort
1 parent e58c462 commit 5e3a0d4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Diff for: InsertionSort.python

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
3+
array=[];
4+
5+
# input
6+
print ("Enter any 6 Numbers for Unsorted Array : ");
7+
for i in range(0, 6):
8+
n=input();
9+
array.append(int(n));
10+
11+
# Sorting
12+
print("")
13+
for i in range(1, 6):
14+
temp=array[i]
15+
j=i-1;
16+
while(j>=0 and temp<array[j]):
17+
array[j+1]=array[j];
18+
j-=1;
19+
array[j+1]=temp;
20+
21+
# Output
22+
for i in range(0,6):
23+
print(array[i]);
24+
25+
26+
27+

0 commit comments

Comments
 (0)