767 views

1 Answer

0 votes
0 votes
Insertion-Sort(A,n)  //A[1....n]

   For j <- 2 to n

        do Key <- A[j]

           i <-  j-1

        while(i>0 and A[i] < Key) 

             do A[i+1] <- A[i]

                i <- i-1

        A[i+1] <- Key

 

Related questions

0 votes
0 votes
1 answer
2
akash.dinkar12 asked Jun 27, 2019
1,711 views
What value of $q$ does PARTITION return when all elements in the array $A[p..r]$ have the same value? Modify PARTITION so that $q=\lfloor(p+r)/2 \rfloor$ when all element...
1 votes
1 votes
1 answer
3
akash.dinkar12 asked Jun 26, 2019
1,772 views
Using Figure $2.4$ as a model, illustrate the operation of merge sort on the array $A=\langle 3,41,52,26,38,57,9,49 \rangle $