173k views
1 vote
Consider the following list. list = {24, 20, 10, 75, 70, 18, 60, 35} Suppose that list is sorted using the insertion sort algorithm as discussed in the book. What is the resulting list after two passes of the sorting phase; that is, after three iterations of the for loop?a. list = {10, 18, 20, 24, 75, 70, 60, 35}b. list = {10, 20, 24, 75, 70, 18, 60, 35}c. list = {10, 18, 20, 24, 35, 70, 60, 75}d. list = {10, 20, 20, 18, 35, 70, 60, 75}

User Mitzi
by
5.5k points

1 Answer

3 votes

Answer:

Option B

10,20,24,75,70,18,60,35

Step-by-step explanation:

The first, second and third iteration of the loop will be as follows

insertion sort iteration 1: 20,24,10,75,70,18,60,35

insertion sort iteration 2:10,20,24,75,70,18,60,35

insertion sort iteration 3: 10,20,24,75,70,18,60,35

User ZeroDefect
by
4.8k points