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?
1a)Giving an array of integers A[1:8] ={5, 1, 3, 2, 7, 6, 8, 4}. What is...
1a)Giving an array of integers A[1:8] ={5, 1, 3, 2, 7, 6, 8, 4}. What is the running time of the insertion sort if both A[1..n/2] and A[n/2+1,n] are also sorted. Justify your answer. 2-illustrate the operation of RADIX-SORT on the following list of English words: COW, DOG, SEA, RUG, ROW, MOB, BOX, TAB, BAR, EAR, TAR, DIG, TEA, NOW, FOX. 3-Use counting sort, sort the following numbers: 4, 2, 5, 4, 2, 3, 0, 2, 4, 3
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 = [4, −9, 4] b = [7, 2, 3] c = [5, −8, 9] d...
a = [4, −9, 4] b = [7, 2, 3] c = [5, −8, 9] d = [1, −3, 2] e = [6, −2, −5, 9] f = [4, −3, 7, 5] g = [1, 3, −1, 5] h = [7, −5, 5] i = [5, 13, −7, 11] Express the hyperplane implicitly or explicitly given the following a) a and h b) f and i c) e, f, and g d) The hyperplane containing b, c and d can...
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...
Matrix A2= [1 2 3; 4 5 6; 7 8 9; 3 2 4; 6 5...
Matrix A2= [1 2 3; 4 5 6; 7 8 9; 3 2 4; 6 5 4; 9 8 7] Note: TA2 is defined to be a linear transformation that maps any vector x to A2* x. That is TA2 = A2*x. Also the range of the Linear transformation represented by A2 is the same as the column space of A2. l) Find a basis for the null(TA2). m) Find nullity of A2, TA2 and A2tA2. n) Find rank(A2), rank(A2t),...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT