Ask Question
28 September, 09:52

Consider the following list. list = {24, 20, 10, 75, 70, 18, 60, 35}Suppose that list is sorted using the selection sort algorithm as discussed in the book. What is the resulting list after two passes of the sorting phase; that is, after two iterations of the outer for loop? list = {10, 18, 24, 20, 75, 70, 60, 35}list = {10, 18, 20, 24, 75, 70, 60, 35}list = {10, 18, 24, 75, 70, 20, 60, 35}list = {10, 20, 24, 75, 70, 20, 60, 35}

+4
Answers (1)
  1. 28 September, 10:20
    0
    list = {10, 18, 24, 75, 70, 20, 60, 35}

    Explanation:

    In selection sort 1st element of array is compared with all elements in list. If there is any element smaller than any other element in the list, that will be swap with first element as

    1st iteration:

    in given list first element is 24, this will compare with whole list and find the number that is smaller than any other element in list. there 10 is smallest element in the list so in first iteration the list is given as:

    list = {10, 20, 24, 75, 70, 18, 60,35}

    2nd Iteration:

    After first iteration the smallest element of list will comes at first position. Now we start with 2nd position of list. 2nd element of the list will be compared with all other elements except 1st element. The 2nd smallest element of the list will be replaced with 2nd element of array.

    In 2nd iteration, 18 is 2nd smallest element in the list so that will be swap with 2nd element of list. now the list is given as after

    list = {10, 18, 24, 75, 70, 20, 60, 35}
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Consider the following list. list = {24, 20, 10, 75, 70, 18, 60, 35}Suppose that list is sorted using the selection sort algorithm as ...” 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