Algorithms | InsertionSort | Question 1

Last Updated :
Discuss
Comments

Consider an array of elements arr[5]= {5,4,3,2,1} , what are the steps of insertions done while doing insertion sort in the array.  

4 5 3 2 1

3 4 5 2 1

2 3 4 5 1

1 2 3 4 5

5 4 3 1 2

5 4 1 2 3

5 1 2 3 4

1 2 3 4 5

4 3 2 1 5

3 2 1 5 4

2 1 5 4 3

1 5 4 3 2

4 5 3 2 1

2 3 4 5 1

3 4 5 2 1

1 2 3 4 5

Share your thoughts in the comments