s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time int64 0 100 | memory stringlengths 4 6 | code_size int64 15 14.7k | code stringlengths 15 14.7k | problem_id stringlengths 6 6 | problem_description stringlengths 358 9.83k | input stringlengths 2 4.87k | output stringclasses 807
values | __index_level_0__ int64 1.1k 1.22M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s556586878 | p02255 | u844704750 | 1498961383 | Python | Python3 | py | Accepted | 30 | 8064 | 392 | N = int(input())
A = list(map(int, input().split(" ")))
def print_list(A):
for a in A[:-1]:
print ("%d "%a, end="")
print(A[-1])
def InsertionSort(A, N):
print_list(A)
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,782 |
s769034459 | p02255 | u735204496 | 1498976292 | Python | Python | py | Accepted | 10 | 6464 | 587 | import sys
def insert_sort(array):
for i in range(0, len(array)):
v = array[i]
j = i - 1
while (j >= 0) and (array[j] > v):
array[j + 1] = array[j]
j -= 1
array[j + 1] = v
print print_list(array)
return array
def print_list(array):
s = ""
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,783 |
s349763569 | p02255 | u078245719 | 1499427286 | Python | Python3 | py | Accepted | 30 | 7604 | 201 | s = int(input())
A = input().split()
for i in range(s):
v = A[i]
j = i - 1
while j >=0 and int(A[j]) > int(v):
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(" ".join(A)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,784 |
s860162081 | p02255 | u490583481 | 1499691249 | Python | Python | py | Accepted | 10 | 6380 | 345 | def insertionSort(*args):
l = list(args)
print ' '.join(map(str, l))
for i in range(1, n):
v = l[i]
j = i - 1
while j >= 0 and l[j] > v:
l[j + 1] = l[j]
j -= 1
l[j + 1] = v
print ' '.join(map(str, l))
n = input()
l = map(int, raw_input().s... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,785 |
s893270499 | p02255 | u193453446 | 1499842139 | Python | Python3 | py | Accepted | 20 | 7772 | 1,080 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
?????\?????????
N ??????????´????????????°??? A ????????????????????????????????\????????????????????°????????????????????????????????????
1 insertionSort(A, N) // N??????????´??????????0-?????????????????????A
2 for i ??? 1 ?????? N-1 ?????§
3 v = A[i]
4 j ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,786 |
s690219228 | p02255 | u264972437 | 1500209789 | Python | Python3 | py | Accepted | 30 | 7724 | 298 | def insertionSort(data):
for old in range(len(data)):
new = old
while new>0 and data[old]<data[max(0,new-1)]:
new -= 1
i = data.pop(old)
data.insert(new,i)
yield data
input()
data = [int(s) for s in input().split()]
[print(' '.join([str(i) for i in d])) for d in insertionSort(data)] | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,787 |
s823383675 | p02255 | u716198574 | 1500212025 | Python | Python3 | py | Accepted | 30 | 7608 | 526 | N = int(input())
A = list(map(int, input().split()))
for i in range(N):
# ?????????????±?
v = A[i]
# ????????????????????????????????¨???
j = i - 1
# ?????????????????¨????????????????????§????????????
# ????±? > ??????????±????????????????????±???????????????????1?????????????????? j ?????????... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,788 |
s705299318 | p02255 | u956645355 | 1500259302 | Python | Python3 | py | Accepted | 20 | 8004 | 358 | def main():
N = int(input())
A = tuple(map(int, input().split()))
a = list(A)
print(*a, sep=' ')
insertionSort(a, N)
def insertionSort(a, n):
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,789 |
s475117189 | p02255 | u663910047 | 1500470805 | Python | Python3 | py | Accepted | 20 | 7712 | 217 | n = int(input())
k = [int(i) for i in input().split()]
for i in range(n):
v = k[i]
j = i-1
while j >= 0 and k[j] > v:
k[j+1] = k[j]
j-=1
k[j+1] =v
print(' '.join(map(str, k)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,790 |
s016987589 | p02255 | u387437217 | 1500515659 | Python | Python3 | py | Accepted | 30 | 7604 | 222 | n=int(input())
A=list(map(int,input().split()))
for i in range(n):
v=A[i]
j=i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
B=A.copy()
B=list(map(str,B))
print(" ".join(B)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,791 |
s230305738 | p02255 | u387437217 | 1500516340 | Python | Python3 | py | Accepted | 30 | 8036 | 175 | n=int(input())
A=list(map(int,input().split()))
for i in range(n):
v=A[i]
j=i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,792 |
s169369447 | p02255 | u914146430 | 1500520295 | Python | Python3 | py | Accepted | 20 | 8076 | 242 | def insertionSort(a):
for i,v in enumerate(a):
j=i-1
while j>=0 and a[j]>v:
a[j+1]=a[j]
j-=1
a[j+1]=v
print(*a)
n = int(input())
a = list(map(int,input().split()))
insertionSort(a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,793 |
s043981726 | p02255 | u260980560 | 1501609981 | Python | Python3 | py | Accepted | 20 | 8084 | 191 | n = int(input())
*A, = map(int, input().split())
for i in range(n):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,794 |
s077040344 | p02255 | u510829608 | 1501769430 | Python | Python3 | py | Accepted | 20 | 8024 | 284 | N = int(input())
A = list(map(int, input().split()))
print(*A)
def insertionSort(A, N):
for i in range(1, N):
v = A[i]
j = i-1
while j>= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
insertionSort(A, N) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,795 |
s936926995 | p02255 | u491916705 | 1502078559 | Python | Python | py | Accepted | 10 | 6456 | 468 | n = raw_input()
A = map(int, raw_input().split())
for i in range(0, len(A)):
if i == len(A)-1:
print A[i]
else:
print A[i],
for i in range(1, len(A)):
j = i - 1
tmp = A[i]
while A[j] > tmp and j >= 0:
tmp2 = A[j]
A[j] = tmp
A[j+1] ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,796 |
s116997759 | p02255 | u659034691 | 1502666423 | Python | Python3 | py | Accepted | 20 | 7712 | 349 | # your code goes here
N=int(input())
A=[int(i) for i in input().split()]
B=""
for k in range(N-1):
B+=str(A[k])+" "
B+=str(A[N-1])
print(B)
for i in range(1,N):
j=i-1
v=A[i]
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
B=""
for k in range(N-1):
B+=str(A[k])+" "
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,797 |
s886775376 | p02255 | u614197626 | 1502866661 | Python | Python3 | py | Accepted | 20 | 7736 | 325 | def insertionSort(A,N):
for i in range(1,N):
v=A[i]
j=i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(str(A).replace(",",'').replace("[",'').replace("]",''))
N=int(input())
sl=input()
print(sl)
lis=list(map(int,sl.split()))
insertionSort(l... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,798 |
s246793346 | p02255 | u614197626 | 1502868728 | Python | Python3 | py | Accepted | 30 | 7676 | 325 | def insertionSort(A,N):
for i in range(1,N):
v=A[i]
j=i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(str(A).replace(",",'').replace("[",'').replace("]",''))
N=int(input())
sl=input()
print(sl)
lis=list(map(int,sl.split()))
insertionSort(l... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,799 |
s879445152 | p02255 | u614197626 | 1502868736 | Python | Python3 | py | Accepted | 30 | 7724 | 325 | def insertionSort(A,N):
for i in range(1,N):
v=A[i]
j=i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(str(A).replace(",",'').replace("[",'').replace("]",''))
N=int(input())
sl=input()
print(sl)
lis=list(map(int,sl.split()))
insertionSort(l... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,800 |
s863877516 | p02255 | u853619096 | 1502946317 | Python | Python3 | py | Accepted | 20 | 7656 | 240 | n=int(input())
z=list(map(int,input().split()))
print(' '.join(list(map(str,z))))
for i in range(1,n):
v=z[i]
j=i-1
while j>=0 and z[j]>v:
z[j+1]=z[j]
j-=1
z[j+1]=v
print(' '.join(list(map(str, z)))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,801 |
s329438191 | p02255 | u957021183 | 1503146004 | Python | Python3 | py | Accepted | 20 | 7812 | 602 | # Aizu Problem ALDS_1_1_A: Insertion Sort
#
import sys, math, os
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input2.txt", "rt")
def printA(A):
print(' '.join([str(a) for a in A]))
def insertion_sort(A):
for i in range(1, len(A)):
key = A[i]
# ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,802 |
s258843690 | p02255 | u283452598 | 1503217045 | Python | Python3 | py | Accepted | 20 | 7652 | 240 | num = int(input())
array = list(map(int,input().split()))
for i in range(num):
v = array[i]
j = i-1
while j >=0 and array[j]>v:
array[j+1] = array[j]
j -= 1
array[j+1] = v
print(" ".join(map(str,array))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,803 |
s977534085 | p02255 | u733159526 | 1503293424 | Python | Python3 | py | Accepted | 40 | 8440 | 863 | def output(list):
for i,row in enumerate(list):
if i == 0:
print(row,end='')
else:
print('',row,end='')
def main():
s = input()
s_list = []
s_list = list(map(int,input().split()))
output(s_list)
print()
i = 0
for count in range(len(s_list)-1... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,804 |
s479795756 | p02255 | u881590806 | 1503297328 | Python | Python | py | Accepted | 10 | 6296 | 304 | def sort(a):
n = len(a)
for i in range(1,n):
for j in range(i):
p = i-j
if a[p] < a[p-1]:
a[p], a[p-1] = a[p-1], a[p]
print ' '.join(map(str, a))
n = int(raw_input())
a = map(int, raw_input().split(' '))
print ' '.join(map(str, a))
sort(a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,805 |
s889397930 | p02255 | u821624310 | 1503307152 | Python | Python3 | py | Accepted | 30 | 8088 | 376 | def print_1(array):
for i in range(len(array)):
if i == len(array) - 1:
print(array[i])
else:
print(array[i], end=" ")
N = int(input())
A = [int(n) for n in input().split()]
print_1(A)
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,806 |
s632661844 | p02255 | u633333374 | 1504273166 | Python | Python | py | Accepted | 10 | 6380 | 210 | n = int(input())
a = map(int,raw_input().split())
for i in range(n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print " ".join(map(str,a)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,807 |
s317267978 | p02255 | u146816547 | 1504509707 | Python | Python | py | Accepted | 10 | 6456 | 328 | def insertionSort(A, N):
for i in range(1, N):
print " ".join(map(str, A))
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
N = int(raw_input())
A = map(int, raw_input().split())
insertionSort(A, N)
print " ".join(map(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,808 |
s631954887 | p02255 | u146816547 | 1504510453 | Python | Python | py | Accepted | 10 | 6376 | 325 | def insertionSort(A, N):
for i in range(1, N):
print " ".join(map(str, A))
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
N = int(raw_input())
A = map(int, raw_input().split())
insertionSort(A, N)
print " ".join(map(str... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,809 |
s072470212 | p02255 | u153665391 | 1504618329 | Python | Python3 | py | Accepted | 20 | 7992 | 195 | n = int(input())
a = list(map(int, input().split()))
for i in range(n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(*a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,810 |
s176960788 | p02255 | u153665391 | 1504697445 | Python | Python3 | py | Accepted | 20 | 8000 | 233 | nums = int(input())
array = list(map(int, input().split()))
for i in range( nums ):
v = array[i]
j = i - 1
while j >= 0 and array[j] > v:
array[j+1] = array[j]
j -= 1
array[j+1] = v
print(*array) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,811 |
s384131886 | p02255 | u343251190 | 1505026764 | Python | Python3 | py | Accepted | 30 | 8200 | 299 | n = int(input())
data = list(map(int, input().split()))
def insertion_sort(A, N):
print(*A)
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
insertion_sort(data, n) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,812 |
s523065618 | p02255 | u354053070 | 1505105621 | Python | Python3 | py | Accepted | 50 | 7700 | 224 | N = int(input())
A = list(map(int, input().split()))
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(" ".join(list(map(str, A)))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,813 |
s510859447 | p02255 | u633333374 | 1505393831 | Python | Python | py | Accepted | 10 | 6460 | 231 | n = int(input())
lst = map(int,raw_input().split())
for i in range(len(lst)):
v = lst[i]
j = i - 1
while j >= 0 and lst[j] > v:
lst[j+1] = lst[j]
j -= 1
lst[j+1] = v
print ' '.join(map(str, lst)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,814 |
s371761518 | p02255 | u972637506 | 1505792143 | Python | Python3 | py | Accepted | 20 | 7720 | 215 | n = int(input())
l = list(map(int, input().split()))
for i in range(n):
v = l[i]
j = i - 1
while j >= 0 and l[j] > v:
l[j+1] = l[j]
j -= 1
l[j+1] = v
print(" ".join(map(str, l))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,815 |
s785499583 | p02255 | u588555117 | 1506089042 | Python | Python3 | py | Accepted | 30 | 8104 | 434 | n = int(input())
array = input().split()
intarr = [int(x) for x in array]
for x in intarr:
if x == intarr[-1]:
print(x)
else:
print(x,end=' ')
for c in range(1,n):
v = intarr[c]
j = c-1
while j>=0 and intarr[j]>v:
intarr[j+1] = intarr[j]
j -= 1
intarr[j+1] = v... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,816 |
s452989797 | p02255 | u071759777 | 1506232019 | Python | Python3 | py | Accepted | 20 | 8108 | 197 | n = int(input())
a = [int(x) for x in input().split()]
print(*a)
for i in range(1, n):
k, j = a[i], i-1
while j >= 0 and a[j] > k:
a[j+1], j = a[j], j-1
a[j+1] = k
print(*a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,817 |
s489763157 | p02255 | u071759777 | 1506232266 | Python | Python3 | py | Accepted | 20 | 8060 | 184 | n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
k, j = a[i], i-1
while j >= 0 and a[j] > k:
a[j+1], j = a[j], j-1
a[j+1] = k
print(*a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,818 |
s591519542 | p02255 | u917432951 | 1506326396 | Python | Python3 | py | Accepted | 20 | 7724 | 318 | if __name__ == '__main__':
N = (int)(input())
A = list(map(int,input().split()))
print(' '.join(map(str,A)))
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j = j -1
A[j+1] = v
print(' '.join(map(str,A))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,819 |
s064694246 | p02255 | u343251190 | 1506455460 | Python | Python3 | py | Accepted | 20 | 8096 | 283 | n = int(input())
data = list(map(int, input().split()))
def insertionsort(a, n):
for i in range(n):
v = a[i]
j = i - 1;
while (j >= 0 and a[j] > v):
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(*a)
insertionsort(data, n) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,820 |
s581001386 | p02255 | u802537549 | 1506510228 | Python | Python3 | py | Accepted | 20 | 8000 | 219 | N = int(input())
A = list(map(int, input().split()))
print(*A)
for i in range(1, len(A)):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,821 |
s276747105 | p02255 | u027634846 | 1507138155 | Python | Python3 | py | Accepted | 40 | 8484 | 624 | def inserts(N):
k = 1
for n in N:
print(n, end='')
if k < len(N):
print(' ', end='')
k += 1
print('')
for i in range(1,len(N)):
# ?????????????´??????????????????£????????¨?????????
v = N[i]
j = i - 1
while j >= 0 and N[j] > v:
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,822 |
s661519516 | p02255 | u792145349 | 1507512203 | Python | Python3 | py | Accepted | 20 | 7776 | 352 | N = int(input())
A = list(map(int, input().split()))
def insertionSort(A,N):
for i in range(1,N):
print(" ".join(map(str, A)))
v = A[i]
j = i -1
while (j >= 0) & (A[j]>v):
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(map(st... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,823 |
s025576987 | p02255 | u957840591 | 1507539947 | Python | Python3 | py | Accepted | 20 | 7712 | 639 | def inputInline():
N = int(input())
numbers = list(map(int, input().split(" ")))
return numbers
def insertionSort(numbers):
N = len(numbers)
for i in range(1, N):
print(" ".join(list(map(str, numbers))))
j = i - 1
temp = numbers[i]
while True:
if j == -1... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,824 |
s455030105 | p02255 | u742466022 | 1507618063 | Python | Python3 | py | Accepted | 20 | 7800 | 258 | n=int(input())
a=[int(i) for i in input().split()]
aaa=" ".join(map(str,a))
print(aaa)
for i in range(1,n):
key=a[i]
j=i-1
while j >= 0 and a[j] > key:
a[j+1]=a[j]
j=j-1
a[j+1]=key
aaa=" ".join(map(str,a))
print(aaa) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,825 |
s469807662 | p02255 | u973998699 | 1507722454 | Python | Python3 | py | Accepted | 30 | 7692 | 318 | #! /usr/bin/env python
# -*- coding : utf-8 -*-
input()
seq = [int(x) for x in input().split()]
for i in range(0, len(seq)):
key = seq[i]
j = i - 1
assert isinstance(i, int)
while j >= 0 and seq[j] > key:
seq[j + 1] = seq[j]
j -= 1
seq[j + 1] = key
print(' '.join(map(str,seq))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,826 |
s673368522 | p02255 | u688488162 | 1507898400 | Python | Python3 | py | Accepted | 30 | 8088 | 318 | n = int(input())
a = list(map(int,input().split()))
for i in range(n):
v = a[i]
j = i-1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j = j-1
a[j+1] = v
for k in range(n):
if k == n-1:
print(a[k],end='')
else:
print(a[k],end=' ')
print() | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,827 |
s380891900 | p02255 | u480053997 | 1508136695 | Python | Python3 | py | Accepted | 20 | 7720 | 265 | N, A = int(input()), list(map(int, input().split()))
print(' '.join([str(a) for a in A]))
for i in range(1, N):
v= A[i]
j= i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(' '.join([str(a) for a in A])) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,828 |
s287007089 | p02255 | u576398884 | 1508198928 | Python | Python3 | py | Accepted | 20 | 7792 | 340 | def pd(A):
print(" ".join(map(str,A)))
def insertionSort(A, N):
pd(A)
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
pd(A)
return A
n = int(input())
a = list(map(int, input().split()))... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,829 |
s496684202 | p02255 | u891342686 | 1508254279 | Python | Python3 | py | Accepted | 50 | 7696 | 294 | def insertionSort(A,N):
for i in range(N):
v = A[i]
j = i -1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -=1
A[j+1] = v
print(" ".join(map(str,A)))
N = int(input())
A = []
A = list(map(int,input().split()))
insertionSort(A,N) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,830 |
s328060760 | p02255 | u998851054 | 1508317157 | Python | Python3 | py | Accepted | 30 | 8216 | 375 | a = []
def outputList(a):
for i in range(len(a)):
if i != len(a)-1:
print("%d"%a[i],end=' ')
else:
print("%d"%a[i],end='\n')
n = int(input().strip())
for i in input().split():
a.append(int(i))
if len(a)==n:
break
for i in range(1,len(a)):
outputList(a)
key = a[i]
j = i - 1
while j >= 0 and a[j] > ke... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,831 |
s108010997 | p02255 | u949517845 | 1508760730 | Python | Python3 | py | Accepted | 30 | 7788 | 409 | def insertionSort(lst, n):
for i in range(1, n):
v = lst[i]
j = i - 1
while j >= 0 and lst[j] > v:
lst[j+1] = lst[j]
j = j - 1
lst[j+1] = v
print(" ".join([str(n) for n in lst]))
if __name__ == "__main__":
n = int(input())
lst = [int(n) for n... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,832 |
s311077101 | p02255 | u949517845 | 1508843166 | Python | Python3 | py | Accepted | 30 | 7808 | 419 | def insertionSort(lst, n):
print(" ".join([str(n) for n in lst]))
for i in range(1, n):
v = lst[i]
for j in range(0, i):
if lst[j] > v:
lst.insert(j, lst.pop(i))
break
print(" ".join([str(n) for n in lst]))
return lst
if __name__ == "__... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,833 |
s181139168 | p02255 | u197670577 | 1508903410 | Python | Python | py | Accepted | 10 | 6464 | 400 | def insersionSort(A, N):
for i in range(1, N):
print " ".join([str(k) for k in A])
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
return A
if __name__ == "__main__":
N = int(raw_input())
A = map(int, raw_inpu... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,834 |
s612807022 | p02255 | u110907458 | 1509264387 | Python | Python3 | py | Accepted | 20 | 7696 | 214 | N = int(input())
A = list (map(int,input().split()))
for i in range(N):
v = A[i]
j = i -1
while (j >= 0) and (A[j]>v):
A[j+1] = A[j]
j -= 1
A[j+1]= v
print(" ".join(map(str,A))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,835 |
s465144184 | p02255 | u043968625 | 1509278653 | Python | Python3 | py | Accepted | 60 | 8136 | 358 | kazu=int(input())
A=[int(i) for i in input().split()]
# kazu=6
# A=[5,2,4,6,1,3]
j=0
for i in range(kazu - 1):
print(A[i], end=" ")
print(A[kazu-1])
for i in range(1,kazu):
v=A[i]
j=i-1
while j>=0 and A[j] >v:
A[j+1]=A[j]
j =j -1
A[j+1]=v
for i in range(kazu-1):
pr... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,836 |
s939710142 | p02255 | u970743870 | 1509768289 | Python | Python3 | py | Accepted | 30 | 8052 | 308 | def insertion_sort(A, N):
for i in range(1, N):
v = A[i]
j = i - 1
print(*A)
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
return A
N = int(input())
A = list(map(int, input().split()))
A = insertion_sort(A, N)
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,837 |
s131851258 | p02255 | u846136461 | 1509960500 | Python | Python | py | Accepted | 10 | 6468 | 299 | n = int(raw_input())
a = map(int, raw_input().split())
def print_list(list):
for i in range(len(list)-1):
print(list[i]),
print(list[len(list)-1])
#print("")
print_list(a)
for i in range(1,n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print_list(a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,838 |
s360339172 | p02255 | u626266743 | 1510020201 | Python | Python3 | py | Accepted | 30 | 7996 | 198 | N = int(input())
A = list(map(int, input().split()))
for i in range(N):
v = A[i]
j = i - 1
while((j >= 0) and A[j] > v):
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,839 |
s765702987 | p02255 | u424457654 | 1510032164 | Python | Python3 | py | Accepted | 20 | 8124 | 194 | N = int(input())
a = list(map(int, input().split()))
print(*a)
for i in range(1, N):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j + 1] = a[j]
j -= 1
a[j + 1] = v
print(*a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,840 |
s075236449 | p02255 | u426534722 | 1510153773 | Python | Python3 | py | Accepted | 20 | 8152 | 345 | import sys
readline = sys.stdin.readline
def insertionSort(n, A):
print(*A)
for i in range(1, n):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(*A)
n = int(readline())
A = [int(j) for j in readline().split(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,841 |
s747331205 | p02255 | u776758454 | 1510191262 | Python | Python3 | py | Accepted | 20 | 7792 | 334 | def main():
n = int(input())
arr = list(map(int,input().split()))
for i in range(1, len(arr)):
j = i - 1
v = arr[i]
print(' '.join(map(str,arr)))
while j >= 0 and arr[j] > v:
arr[j+1] = arr[j]
j -= 1
arr[j+1] = v
print(' '.join(map(str,a... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,842 |
s827294935 | p02255 | u933096856 | 1510304940 | Python | Python3 | py | Accepted | 50 | 8092 | 111 | n=int(input())
l=list(map(int, input().split()))
for i in range(1,n+1):
l[0:i]=sorted(l[0:i])
print(*l) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,843 |
s730267149 | p02255 | u933096856 | 1510305058 | Python | Python3 | py | Accepted | 40 | 8112 | 111 | n=int(input())
l=list(map(int, input().split()))
for i in range(1,n+1):
l[0:i]=sorted(l[0:i])
print(*l) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,844 |
s921844955 | p02255 | u409699893 | 1510887707 | Python | Python3 | py | Accepted | 20 | 8000 | 229 | n = int(input())
x = list(map(int,input().split()))
print (*x)
for i in range(1,n):
v = x[i]
j = i - 1
while j >= 0:
if x[j] > v:
x[j + 1] = x[j]
x[j] = v
j += -1
print (*x) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,845 |
s053003021 | p02255 | u784787519 | 1510931846 | Python | Python3 | py | Accepted | 30 | 8032 | 548 | num = int(input())
A = list(map(int, input().split(' ')))
def intersection(A,N):
for i in range(len(A)): #output
if i==len(A)-1:
print(A[i])
else:
print(A[i], end=' ')
for i in range(1,N):
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,846 |
s393330004 | p02255 | u433154529 | 1510974446 | Python | Python3 | py | Accepted | 30 | 7772 | 224 | n = int(input())
a = [int(i) for i in input().split()]
for i in range(len(a)):
v = a[i]
j = i - 1
while j >= 0 and a[j]>v:
a[j+1] = a[j]
j-=1
a[j+1]=v
print(" ".join([str(i) for i in a])) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,847 |
s966519415 | p02255 | u433154529 | 1510974949 | Python | Python3 | py | Accepted | 20 | 7692 | 224 | n = int(input())
a = [int(i) for i in input().split()]
for i in range(len(a)):
v = a[i]
j = i - 1
while j >= 0 and a[j]>v:
a[j+1] = a[j]
j-=1
a[j+1]=v
print(" ".join([str(i) for i in a])) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,848 |
s474037778 | p02255 | u045830275 | 1511280848 | Python | Python3 | py | Accepted | 20 | 7720 | 399 | def main() :
n = int(input())
lst = [int(i) for i in input().split()]
print(" ".join(map(str, lst)));
for i in range(1,n) :
for j in reversed(range(i+1)) :
if j == 0 :
break
elif lst[j] < lst[j-1]:
lst[j], lst[j-1] = lst[j-1], lst[j]
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,849 |
s114768880 | p02255 | u747709646 | 1511423036 | Python | Python3 | py | Accepted | 30 | 7708 | 264 | n = int(input())
A = list(map(int, input().split()))
print(' '.join(list(map(str, A))))
for i in range(1,n):
key = A[i]
j = i - 1
while j >= 0 and A[j] > key:
A[j+1] = A[j]
j -= 1
A[j+1] = key
print(' '.join(list(map(str, A)))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,850 |
s460572165 | p02255 | u650459696 | 1511844134 | Python | Python3 | py | Accepted | 30 | 5980 | 199 | n = int(input())
a = list(map(int, input().split()))
for i in range(n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j + 1] = a[j]
j -= 1
a[j + 1] = v
print(*a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,851 |
s490589928 | p02255 | u928329738 | 1511960249 | Python | Python3 | py | Accepted | 20 | 5596 | 286 | n = int(input())
numbs = list(map(int,input().split()))
print(' '.join(map(str,numbs)))
for i in range(1,len(numbs)):
key = numbs[i]
j = i-1
while j >=0 and numbs[j] > key:
numbs[j+1] = numbs[j]
j -= 1
numbs[j+1] = key
print(' '.join(map(str,numbs))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,852 |
s744814376 | p02255 | u424041287 | 1512111610 | Python | Python3 | py | Accepted | 20 | 5604 | 380 | def insertionSort(A, N):
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
t = str(A[0])
for i in range(1,N):
t = t + " " + str(A[i])
print(t)
n = int(input(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,853 |
s374265965 | p02255 | u488038316 | 1512232132 | Python | Python3 | py | Accepted | 20 | 5608 | 343 | # -*- coding:utf-8
def main():
N = int(input())
A = list(map(int, input().split()))
insertionSort(A, N)
print(' '.join(map(str, A)))
def insertionSort(A, N):
for i in range(1, N):
print(' '.join(map(str, A)))
v = A[i]
j = i-1
while(j>=0 and A[j]>v):
A[j+1] = A[j]
j -= 1
A[j+1] = v
if __name__... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,854 |
s476292943 | p02255 | u255925718 | 1512384583 | Python | Python | py | Accepted | 10 | 4652 | 283 | NN=raw_input()
N=raw_input()
N = [int(i) for i in N.split()]
print ' '.join([str(k) for k in N])
for i in range(1,int(NN)):
key = N[i]
j = i - 1
while (j >= 0) and (N[j] > key):
N[j+1] = N[j]
j=j-1
N[j+1] = key
print ' '.join([str(k) for k in N]) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,855 |
s584798574 | p02255 | u908984540 | 1512639200 | Python | Python3 | py | Accepted | 30 | 5984 | 619 | def show_list(target):
for i, item in enumerate(target):
if i == len(target) - 1:
print(item)
else:
print(item, end=" ")
def insection_sort(target):
for i in range(1, len(target)):
show_list(target)
j = i - 1
while j >= 0:
if target[j]... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,856 |
s619871904 | p02255 | u877343898 | 1512787658 | Python | Python3 | py | Accepted | 20 | 5600 | 451 | n = int(input())
line = input()
arr = line.split(" ")
nums = []
for c in range(n):
nums.append(int(arr[c]))
def trace(n_list):
n_list_str = ""
for num in n_list:
n_list_str += str(num)
n_list_str += " "
print(n_list_str.rstrip(" "))
print(line)
for i in range(1, n):
v =... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,857 |
s891015299 | p02255 | u183079216 | 1513328640 | Python | Python3 | py | Accepted | 20 | 5604 | 195 | N=int(input())
A=[int(x) for x in input().split()]
for i in range(N):
v=A[i]
j=i-1
while j>=0 and v<A[j]:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(' '.join(map(str,A))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,858 |
s129878521 | p02255 | u530663965 | 1513348079 | Python | Python3 | py | Accepted | 20 | 6036 | 792 | import sys
ERROR_INPUT = 'input is invalid'
def main():
n = get_length()
arr = get_array(length=n)
print(*arr)
insetionSort(li=arr, length=n)
return 0
def get_length():
n = int(input())
if n < 0 or n > 100:
print(ERROR_INPUT)
sys.exit(1)
else:
return n
def... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,859 |
s252527810 | p02255 | u530663965 | 1513348140 | Python | Python3 | py | Accepted | 20 | 5976 | 670 | import sys
ERROR_INPUT = 'input is invalid'
def main():
n = get_length()
arr = get_array(length=n)
insetionSort(li=arr, length=n)
return 0
def get_length():
n = int(input())
if n < 0 or n > 100:
print(ERROR_INPUT)
sys.exit(1)
else:
return n
def get_array(lengt... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,860 |
s292235327 | p02255 | u146752763 | 1513562118 | Python | Python | py | Accepted | 10 | 4664 | 384 | # coding:utf-8
def insertionSort(A, N):
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
for i in A:
print i,
else:
print
N = input()
A = map(int, raw_input().spli... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,861 |
s188242964 | p02255 | u150984829 | 1513671806 | Python | Python3 | py | Accepted | 20 | 5980 | 142 | n=int(input())
a=input().split()
for i in range(n):
k=int(a[i])
j=i-1
while j>=0 and int(a[j])>k:
a[j+1]=a[j]
j-=1
a[j+1]=k
print(*a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,862 |
s219302558 | p02255 | u150984829 | 1513671836 | Python | Python3 | py | Accepted | 20 | 5976 | 147 | n=int(input())
a=list(map(int,input().split()))
for i in range(n):
k=a[i]
j=i-1
while j>=0 and a[j]>k:
a[j+1]=a[j]
j-=1
a[j+1]=k
print(*a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,863 |
s365094710 | p02255 | u810198868 | 1513732201 | Python | Python3 | py | Accepted | 30 | 5608 | 268 | n = int(input())
A = [int(x) for x in input().split()]
print(" ".join([str(x) for x in A]))
for i in range(1, n):
key = A[i]
j = i-1
while j >=0 and A[j] > key:
A[j+1] = A[j]
j -= 1
A[j+1] = key
print(" ".join([str(x) for x in A])) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,864 |
s670101857 | p02255 | u406002631 | 1514038364 | Python | Python3 | py | Accepted | 20 | 5608 | 313 | n = int(input())
a = list(map(int, input().split()))
def insertionSort(a,n):
for i in range(n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j + 1] = a[j]
j -= 1
a[j + 1] = v
print(" ".join(map(str, a)))
insertionSort(a,n)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,865 |
s459719561 | p02255 | u609315369 | 1514121702 | Python | Python3 | py | Accepted | 30 | 6316 | 531 | #coding: UTF-8
import sys
class Algo:
@staticmethod
def insersion_sort(A, N):
for i in range(1, N):
for k in A:
if k==A[len(A)-1]:
print(k)
else:
print(k, " ", sep="", end="")
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,866 |
s297916304 | p02255 | u409571842 | 1514121833 | Python | Python3 | py | Accepted | 40 | 6316 | 531 | #coding: UTF-8
import sys
class Algo:
@staticmethod
def insersion_sort(A, N):
for i in range(1, N):
for k in A:
if k==A[len(A)-1]:
print(k)
else:
print(k, " ", sep="", end="")
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,867 |
s578174579 | p02255 | u741801763 | 1514194461 | Python | Python3 | py | Accepted | 20 | 5988 | 447 | import sys
def print_list(A):
for k in range(len(A)):
sys.stdout.write(str(A[k]))
if not k == len(A) -1: sys.stdout.write(" ")
print()
def insert_sort(A,N):
print_list(A)
for i in range(1,N):
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,868 |
s194294165 | p02255 | u741801763 | 1514382814 | Python | Python3 | py | Accepted | 20 | 5976 | 203 | N = int(input())
A = list(map(int,input().split()))
for i in range(1,N):
print(*A)
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j = j-1
A[j+1]=v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,869 |
s448607150 | p02255 | u972731768 | 1514455012 | Python | Python3 | py | Accepted | 20 | 5980 | 319 | def insertionSort(A,N):
for i in range(1,N):
v = A[i]
j=i-1
while(j>=0 and A[j] > v):
A[j+1] = A[j]
j-=1
A[j+1]=v
print(*A)
if __name__ == '__main__':
N = int(input())
A = [int(i) for i in input().split()]
print(*A)
insertionSort(A,N) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,870 |
s273151484 | p02255 | u972731768 | 1514455160 | Python | Python3 | py | Accepted | 20 | 5976 | 200 | N = int(input())
A = [int(i) for i in input().split()]
print(*A)
for i in range(1,N):
v = A[i]
j=i-1
while(j>=0 and A[j] > v):
A[j+1] = A[j]
j-=1
A[j+1]=v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,871 |
s520041059 | p02255 | u972731768 | 1514455264 | Python | Python3 | py | Accepted | 20 | 5984 | 197 | N = int(input())
A = list(map(int,input().split()))
print(*A)
for i in range(1,N):
v = A[i]
j=i-1
while(j>=0 and A[j] > v):
A[j+1] = A[j]
j-=1
A[j+1]=v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,872 |
s122181879 | p02255 | u972731768 | 1514455477 | Python | Python3 | py | Accepted | 20 | 5976 | 195 | N = int(input())
A = list(map(int,input().split()))
print(*A)
for i in range(1,N):
v = A[i]
j=i-1
while j>=0 and A[j]>v :
A[j+1] = A[j]
j-=1
A[j+1]=v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,873 |
s301344959 | p02255 | u972731768 | 1514455514 | Python | Python3 | py | Accepted | 20 | 5976 | 195 | N = int(input())
A = list(map(int,input().split()))
print(*A)
for i in range(1,N):
v = A[i]
j=i-1
while j>=0 and A[j]>v :
A[j+1] = A[j]
j-=1
A[j+1]=v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,874 |
s310503443 | p02255 | u972731768 | 1514455611 | Python | Python3 | py | Accepted | 20 | 5984 | 210 | N = int(input())
A = list(map(int,input().split()))
print(*A)
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A [j] > v :
A[j + 1] = A[j]
j -= 1
A[j+1] = v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,875 |
s447749212 | p02255 | u972731768 | 1514455833 | Python | Python3 | py | Accepted | 20 | 5980 | 213 | N = int(input())
A = list(map(int,input().split()))
print(*A)
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A [j] > v :
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,876 |
s438779985 | p02255 | u972731768 | 1514455859 | Python | Python3 | py | Accepted | 20 | 5984 | 212 | N = int(input())
A = list(map(int,input().split()))
print(*A)
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A [j] > v :
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,877 |
s077516078 | p02255 | u972731768 | 1514455932 | Python | Python3 | py | Accepted | 20 | 5984 | 212 | N = int(input())
A = list(map(int,input().split()))
print(*A)
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A [j] > v :
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(*A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,878 |
s502708898 | p02255 | u972731768 | 1514455980 | Python | Python3 | py | Accepted | 20 | 5976 | 216 | N = int(input())
A = list(map(int,input().split()))
print( *A )
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A [j] > v :
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print( *A ) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,879 |
s167153267 | p02255 | u793923674 | 1514517221 | Python | Python3 | py | Accepted | 30 | 5980 | 539 | def insertion_sort(A, N):
for i in range(1, N):
for s in A:
tmp = str(s) if A[0] == s else " "+str(s)
print(tmp, end="")
print()
j = i-1
v = A[i]
while v < A[j] and j >= 0:
A[j+1] = A[j]
j = j-1
A[j+1] = v
for s in ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,880 |
s815582334 | p02255 | u585035894 | 1514527366 | Python | Python3 | py | Accepted | 20 | 5980 | 288 | def insersion_sort(a):
print(*a)
n = len(a)
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(*a)
input()
insersion_sort([int(i) for i in input().split()]) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,881 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.