+3 votes
in Class 12 by kratos

Write an algorithm for insertion sort method.

1 Answer

+2 votes
by kratos
 
Best answer

Step 1: for i = 1 to n-1 Repeat step 2
Step 2: for j = i downto 1 Repeat step 3
Step 3: is ( a[j] < a[j-1])? then
temp = a[j]
A[j] = a[j-1]
A[j-1] = temp [ end of j loop]
[ end of i loop]

...