Question

In: Computer Science

Ex 1. Show the contents of the array of integers 5 7 4 9 8 5...

Ex 1. Show the contents of the array of integers 5 7 4 9 8 5 6 3 each time a selection sort changes it while sorting

the array into ascending order.

Initial array:   5 7 4 9 8 5 6 3

ANSWER (Hint there are 8 lines, Show Array after each selection and swap):

Solutions

Expert Solution

Initial array:   5 7 4 9 8 5 6 3

Iteration: 1

Find the minimum element in the array[0..8]

Minimum is 3, swap with the 0 index

Updated array : 3 7 4 9 8 5 6 5

Iteration: 2

Find the minimum element in the array[1..8]

Minimum is 4, swap with the 1 index

Updated array : 3 4 7 9 8 5 6 5

Iteration: 3

Find the minimum element in the array[2..8]

Minimum is 5, swap with the 2 index

Updated array : 3 4 5 9 8 7 6 5

Iteration: 4

Find the minimum element in the array[3..8]

Minimum is 5, swap with the 3 index

Updated array : 3 4 5 5 8 7 6 9

Iteration: 5

Find the minimum element in the array[4..8]

Minimum is 6, swap with the 4 index

Updated array : 3 4 5 5 6 7 8 9

Iteration: 6

Find the minimum element in the array[4..8]

Minimum is 7, swap with the 5 index, NO CHANGE

Updated array : 3 4 5 5 6 7 8 9

Iteration: 7

Find the minimum element in the array[4..8]

Minimum is 8, swap with the 6 index, NO CHANGE

Updated array : 3 4 5 5 6 7 8 9

Iteration: 8

Find the minimum element in the array[4..8]

Minimum is 9, swap with the 7 index, NO CHANGE

Updated array : 3 4 5 5 6 7 8 9

Finally, Sorted array will become 3 4 5 5 6 7 8 9


Related Solutions

1) Define and create an array of integers with the values 5, 7, 8, 9 10,...
1) Define and create an array of integers with the values 5, 7, 8, 9 10, 12 using an initializer list. Print the array. 5. 2) Given the Array below, replace the element at position 3 with the value, 99, using an assignment statement. int [] list = {88, 0, 11, 22, 55, 77}; What is the value of list.length?
A = [4, 5, 9] B = [-4, 5, -7] C = [2, -7, -8, 5]...
A = [4, 5, 9] B = [-4, 5, -7] C = [2, -7, -8, 5] D = [1, -9, 5, -3] E = [3, 3, -1] Uz = 1/|z| ^z d(X,Y) = (Rθ) d = diameter R = Radius θ = Theta Find a. Uc b. d (D, C) c. Let P = B + 3E, UP = d. A x B e. 3B x E f. C x D
x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7...
x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7 9 7 4 6 9 9 -5.48x + 0.17 5.48x + 0.17 -0.17x + 5.48 0.17x + 5.48
A=[ 7 8 -2 -6 7 4 1 ; 2 4 -4 -13 9 9 -12...
A=[ 7 8 -2 -6 7 4 1 ; 2 4 -4 -13 9 9 -12 ; 6 6 0 -9 8 9 -4 ; 1 8 -14 -22 5 8 -1 ; 4 9 -10 -14 7 4 -1] B=[ 19 4 4 14 -3 -7 -5 ; 21 -6 -5 10 14 -2 4 ; 22 -4 5 13 5 -6 4 ; 41 20 0 26 11 -1 -27 ; 29 14 -2 20 3 -4 -19]...
3, 7, 8, 5, 6, 4, 9, 10, 7, 8, 6, 5 Using the previous question...
3, 7, 8, 5, 6, 4, 9, 10, 7, 8, 6, 5 Using the previous question 's scores, If three points were added to every score in this distribution, what would be the new mean? If three points were added to every score in this distribution, what would be the new standard deviation. Remember, you have already calculated population standard deviation in a previous problem. This problem requires two answers.
There is a deck with 42 cards, with 4, 5, 6, 7, 8, 9, A. There...
There is a deck with 42 cards, with 4, 5, 6, 7, 8, 9, A. There are three suits spades, hearts, and clovers. In each suit there are two of each card. So there are two 7 of spades, 7 of hearts, 7 of clovers and so on. Each hand dealt consists of 5 cards. 1. How many hands contains exactly a pair that consists of two cards with the same value? 2. How many hands contains exactly one pair...
Consider the following sorted int array: 1 3 4 5 7 9 10 12 If we...
Consider the following sorted int array: 1 3 4 5 7 9 10 12 If we search for the key value 10 in the array using the binary search algorithm, what is the sequence of indices that will be accessed in the array? (Hint: For a sublist between index values low and high, the middle index is calculated using: (low + high) / 2. So you need to show the sequence of indices of the middle index in each pass.)...
Table: x: 6, 2, 15, 9, 12, 5, 8 y: 8, 9, 4, 7, 6, 9,...
Table: x: 6, 2, 15, 9, 12, 5, 8 y: 8, 9, 4, 7, 6, 9, 8 1) Make the scatter diagram. 2) Find the equation of the regression line using the formulas given in class. They must appear the intermediate steps of substitutions. Round the answers to three decimal places. 3) Find the correlation coefficient using the formulas given in class. Steps should appear intermediates of substitutions. Round the answer to three decimal places. 4) Find the value predicted...
Given the matrix 7 7 -4 12 -5 A = 9 10 2 6 13 8 11 15 4 1 3. a. Sort each column and store the result in an array B.
Given the matrix a. Sort each column and store the result in an array B.b. Sort each row and store the result in an array C.c. Add each column and store the result in an array D.d. Add each row and store the result in an array E.  
(9) Diagonalizing 4 0 1 -7 -5 5. -12 -6 7
(9) Diagonalizing 4 0 1 -7 -5 5. -12 -6 7
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT