Ask Question

Sort the array A = [ 3, 1, 4, 1, 5, 9, 2, 6, 5] using insertion sort and illustrate your solution?

+1
Answers (1)
  1. 5 January, 06:09
    0
    Sorted list : [1, 1, 2, 3, 4, 5, 5, 6, 9]

    Explanation:

    For j = 2 to length of A

    we find the place for A[j] in the sub-array A[1, ..., j]

    Taking i from j-1 to 1, if A[i] is greater than A[j] we shift it to right.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Sort the array A = [ 3, 1, 4, 1, 5, 9, 2, 6, 5] using insertion sort and illustrate your solution? ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers