Question: Python code to sort a list of numbers using insertion - sort algorithm is given. definsertion _ sort ( A ) : '

Python code to sort a list of numbers using insertion-sort algorithm is given. definsertion_sort(A):
"'"' Sort the elements of the list in ascending order"'""
for k in , len(A)):
cur =A[k]
j=k
while j>0 and A[j-1]> cur:
A[j]=A[j-1]
j-=1
A[j]= cur
A=[6,8,2,3,9,4,7,1]
insertion_sort(A)
What will be the value of list 'A' after the for loop is run for two times?
a)6,8,2,3,9,4,7,1
b)2,6,8,3,9,4,7,1
c)1,2,6,8,3,9,4,7
d)6,2,3,4,7,1,8,9
19. What will be the running time of the algorithm given below?
for )=1;i**i
printf("%dln",i*i)
(a
 Python code to sort a list of numbers using insertion-sort algorithm

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!