Question

In: Computer Science

Given the following data, illustrate Selection Sort. index 1 2 3 4 5 6 data 11...

  1. Given the following data, illustrate Selection Sort.

index

1

2

3

4

5

6

data

11

10

21

3

7

5

Solutions

Expert Solution

Selection sort
Original list is [11, 10, 21, 3, 7, 5]
Iteration: 1
   > Replace element 11 with minimum number of remaining list [11, 10, 21, 3, 7, 5]
   > Minimum element found is 3. so, swap it with element at index 0 which is 11
   > List after iteration 1 is [3, 10, 21, 11, 7, 5]

Iteration: 2
   > Replace element 10 with minimum number of remaining list [10, 21, 11, 7, 5]
   > Minimum element found is 5. so, swap it with element at index 1 which is 10
   > List after iteration 2 is [3, 5, 21, 11, 7, 10]

Iteration: 3
   > Replace element 21 with minimum number of remaining list [21, 11, 7, 10]
   > Minimum element found is 7. so, swap it with element at index 2 which is 21
   > List after iteration 3 is [3, 5, 7, 11, 21, 10]

Iteration: 4
   > Replace element 11 with minimum number of remaining list [11, 21, 10]
   > Minimum element found is 10. so, swap it with element at index 3 which is 11
   > List after iteration 4 is [3, 5, 7, 10, 21, 11]

Iteration: 5
   > Replace element 21 with minimum number of remaining list [21, 11]
   > Minimum element found is 11. so, swap it with element at index 4 which is 21
   > List after iteration 5 is [3, 5, 7, 10, 11, 21]

Sorted list is [3, 5, 7, 10, 11, 21]

Related Solutions

Given the data set A = {5, 4, 6, 14, 2, 2, 11, 4, 5, 8,...
Given the data set A = {5, 4, 6, 14, 2, 2, 11, 4, 5, 8, 3, 1, 12, 15, 13}, which is the data of a sample taken from a larger population. Calculate the arithmetic mean Find the median Find the mode Calculate the range Calculate the interquartile range Calculate the mean deviation Calculate the variance Calculate the standard deviation
selection sort for 12, 2, 3, 21, 11, 10,8
selection sort for 12, 2, 3, 21, 11, 10,8
2. Consider the following data: x= 1, 2, 3, 4, 5 y =3, 2, 4, 6,...
2. Consider the following data: x= 1, 2, 3, 4, 5 y =3, 2, 4, 6, 5 By hand, not using Matlab, and showing your work: (a) Compute the correlation coefficient. (b) Find the least-squares line. (c) Find the standard deviation around the least-squares line.
Use counting sort, sort the following numbers: 4, 2, 5, 4, 2, 3, 0, 2, 4,...
Use counting sort, sort the following numbers: 4, 2, 5, 4, 2, 3, 0, 2, 4, 3
Question 1 (of 11)Question 2 (of 11)Question 3 (of 11)Question 4 (of 11)Questions 5 - 6...
Question 1 (of 11)Question 2 (of 11)Question 3 (of 11)Question 4 (of 11)Questions 5 - 6 (of 11)Questions 7 - 9 (of 11)Questions 10 - 11 (of 11)  Save & ExitSubmit   Time remaining: 0:51:30   Problem 7-5A Determine depreciation under three methods (LO7-4) [The following information applies to the questions displayed below.] University Car Wash built a deluxe car wash across the street from campus. The new machines cost $270,000 including installation. The company estimates that the equipment will have a residual...
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.  
Consider the following data table: x 8 5 4 6 2 5 3 y 1 3...
Consider the following data table: x 8 5 4 6 2 5 3 y 1 3 6 3 7 2 5 (15 points) Create a scatterplot of the data either by hand or with a computer.  Does there appear to be a linear relationship between x and y?  If so, what is the strength and direction of the relationship? (20 points) Give the Simple Linear Regression Model, using x as the predictor variable and y as the response variable.  What is the meaning...
Given an array with data 3, 6, 4, 1, 5, 2, 6, 5, 3, 7, 4 using random select to find the 9 th smallest number
Given an array with data 3, 6, 4, 1, 5, 2, 6, 5, 3, 7, 4 using random select to find the 9 th smallest number (use the last element in each sequence as pivot). Show the intermediate steps (the result of each recursive step including the pivot, k’s value and grouping).
Consider the data. xi 1 2 3 4 5 yi 4 7 5 11 15 The...
Consider the data. xi 1 2 3 4 5 yi 4 7 5 11 15 The estimated regression equation for these data is  ŷ = 0.60 + 2.60x. (a)Compute SSE, SST, and SSR using equations SSE = Σ(yi − ŷi)2, SST = Σ(yi − y)2, and SSR = Σ(ŷi − y)2. SSE=SST=SSR= (b) Compute the coefficient of determination r2. r2 = Comment on the goodness of fit. (For purposes of this exercise, consider a proportion large if it is at least...
Consider the data. xi 1 2 3 4 5 yi 4 7 5 11 13 (a)...
Consider the data. xi 1 2 3 4 5 yi 4 7 5 11 13 (a) Compute the mean square error using equation  s2 = MSE = SSE n − 2  . (Round your answer to two decimal places.) (b) Compute the standard error of the estimate using equation s = MSE = SSE n − 2  . (Round your answer to three decimal places.) (c) Compute the estimated standard deviation of b1 using equation sb1 = s Σ(xi − x)2...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT