Ask Question

Write the state of the elements of each of the following arrays after each pass of the outermost loop of the selection sort algorithm has occurred (after each element is selected and moved into place). int[] numbers3 = {8, 5, - 9, 14, 0, - 1, - 7, 3}; int[] numbers4 = {15, 56, 24, 5, 39, - 4, 27, 10};

+1
Answers (1)
  1. 2 October, 03:35
    0
    The following are the explanation given below.

    Explanation:

    In the first case = > 8, 5, - 9, 14, 0, - 1, - 7, 3.

    8, 5, - 9, 14, 0, - 1, - 7, 3 For the first instance, search for the smaller form 1st to 8th as well as move 3rd in the first one. - 9, 8, 5, 14, 0, - 1, - 7, 3 For the second instance, search for the smaller in the second to the 8th and move the last second in the second one. - 9, - 7, 8, 5, 14, 0, - 1, 3 For the third instance, search for the smallest in the third to the 8th and move the last second from the third one. - 9, - 7, - 1, 8, 5, 14, 0, 3 For the fourth instance, search for the smallest in the fourth to the 8th and move the last second from the fourth one. - 9, - 7, - 1, 0, 8, 5, 14, 3 For the fifth instance, search for the smallest in the fifth to the 8th and move the last from the fifth one. - 9, - 7, - 1, 0, 3, 8, 5, 14 For the sixth instance, search for the smallest in the sixth to the 8th and move the last second from the sixth one. - 9, - 7, - 1, 0, 3, 5, 8, 14 are sorted.

    In the second case = > 15, 56, 24, 5, 39, - 4, 27, 10.

    15, 56, 24, 5, 39, - 4, 27, 10 For the first instance, search for the smaller form 1st to 8th as well as move last 3rd from the first one. - 4, 15, 56, 24, 5, 39, 27, 10 For the second instance, search for the smaller in the second to the 8th and move the last fourth in the second one. - 4, 5, 15, 56, 24, 39, 27, 10 For the third instance, search for the smallest in the third to the 8th and move the last from the third one. - 4, 5, 10, 15, 56, 24, 39, 27 For the fourth instance, search for the smallest in the fourth to the 8th and not move that instance it already sorted. - 4, 5, 10, 15, 56, 24, 39, 27 For the fifth instance, search for the smallest in the fifth to the 8th and move the last third from the fifth one. - 4, 5, 10, 15, 24, 56, 39, 27 For the sixth instance, search for the smallest in the sixth to the 8th and move the last from the sixth one. - 4, 5, 10, 15, 24, 27, 56, 39 For the seventh instance, search for the smallest in the seventh to the 8th and move the last from the seventh one. - 4, 5, 10, 15, 24, 27, 39, 56 are sorted.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write the state of the elements of each of the following arrays after each pass of the outermost loop of the selection sort algorithm has ...” 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