Question: Show the details steps in applying Insertion sort on the following array { 2 , 1 0 , 5 , 4 , 0 , 8

Show the details steps in applying Insertion sort on the following array
{2,10,5,4,0,8,1,3}.
Step 1 and Step 2 are given to you. Complete the following steps in the same way as the first 2 steps.
Step 1(Compare 10 and 2):
The first two elements, 2 and 10, are in the correct order, so no changes are needed.
Output Array of step 1: {2,10,5,4,0,8,1,3}
Step 2(Insert 5 in the correct position):
Compare 5 with 10: Swap 5 and 10.
Compare 5 with 2: No change since 5>2.
Output Array of step 2: {2,5,10,4,0,8,1,3}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!