How the insertion sort is done with the array?

It sorts a list of elements by inserting each successive element in the previously sorted sublist.

Consider an array to be sorted A[1],A[2],….A[n]

  1. Pass 1 : A[2] is compared with A[1] and placed them in sorted
  2. Pass 2 : A[3] is compared with both A[1] and A[2] and inserted at an appropriate This makes A[1], A[2],A[3] as a sorted sub array.
  3. Pass n-1 : A[n] is compared with each element in the sub array A[1],A[2],……A[n-1] and inserted at an appropriate
0
Sanisha Maharjan
Jan 23, 2022
More related questions

Questions Bank

View all Questions