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

Ans:

Given that: Sorting sort searches the smallest element and places the top index in an unsorted array.


index

1

2

3

data

11

10

22


Step 1:

(a)

index

1

2

3

data

11

10

22


Min value

11

Index 1

(b)


index

1

2

3

data

11

10

22


Min value

11

Index 2 compare value with min value

Min value

10


(c)


index

1

2

3

data

11

10

22


Min value

10

Index 3 compare value with min value

Swap index 2 value by 1



index

1

2

3

data

10

11

22


Index 1 value is sorted


Step 2:

(a)

index

1

2

3

data

10

11

22


Min value

11

Index 2

(b)

index

1

2

3

data

10

11

22


Min value

11

Index 3 compare value with min value

No swapping



index

1

2

3

data

10

11

22


Till Index 2 value is sorted


Step 3:

(a)

index

1

2

3

data

10

11

22


Min value

22

Index 3


Now sorted Array



index

1

2

3

data

10

11

22


Related Solutions

Given the following data, illustrate Selection Sort. index 1 2 3 4 5 6 data 11...
Given the following data, illustrate Selection Sort. index 1 2 3 4 5 6 data 11 10 21 3 7 5
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...
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 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.  
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT