Question

In: Computer Science

Using the following data set: 100, 50, 20, 70, 200, 30, 130 Apply the selection sort...

Using the following data set:

100, 50, 20, 70, 200, 30, 130

Apply the selection sort algorithm [Show the first four iterations only]

Solutions

Expert Solution

Selection sort
Original list is [100, 50, 20, 70, 200, 30, 130]
Iteration: 1
   > Replace element 100 with minimum number of remaining list [100, 50, 20, 70, 200, 30, 130]
   > Minimum element found is 20. so, swap it with element at index 0 which is 100
   > List after iteration 1 is [20, 50, 100, 70, 200, 30, 130]

Iteration: 2
   > Replace element 50 with minimum number of remaining list [50, 100, 70, 200, 30, 130]
   > Minimum element found is 30. so, swap it with element at index 1 which is 50
   > List after iteration 2 is [20, 30, 100, 70, 200, 50, 130]

Iteration: 3
   > Replace element 100 with minimum number of remaining list [100, 70, 200, 50, 130]
   > Minimum element found is 50. so, swap it with element at index 2 which is 100
   > List after iteration 3 is [20, 30, 50, 70, 200, 100, 130]

Iteration: 4
   > Replace element 70 with minimum number of remaining list [70, 200, 100, 130]
   > Minimum element found is 70. so, swap it with element at index 3 which is 70
   > List after iteration 4 is [20, 30, 50, 70, 200, 100, 130]

Iteration: 5
   > Replace element 200 with minimum number of remaining list [200, 100, 130]
   > Minimum element found is 100. so, swap it with element at index 4 which is 200
   > List after iteration 5 is [20, 30, 50, 70, 100, 200, 130]

Iteration: 6
   > Replace element 200 with minimum number of remaining list [200, 130]
   > Minimum element found is 130. so, swap it with element at index 5 which is 200
   > List after iteration 6 is [20, 30, 50, 70, 100, 130, 200]

Sorted list is [20, 30, 50, 70, 100, 130, 200]


Related Solutions

Sort the following set of numbers using bubble sort, insertion sort, and selection sort. Show the...
Sort the following set of numbers using bubble sort, insertion sort, and selection sort. Show the process step-by-step, and find the time complexity in Big-O notation for each method. For sorting, use ascending order. 49, 7, 60, 44, 18, 105
Using the data set below: Score Frequency 20-30 5 30-40 8 40-50 13 50-60 12 60-70...
Using the data set below: Score Frequency 20-30 5 30-40 8 40-50 13 50-60 12 60-70 5 Draw a Histogram Draw a polygon After listening to YouTube “histogram and polygon,” explain how histogram is different and similar to polygon.
CS 209 Data Structure 1. show how to apply a selection sort on {45, 11, 50,...
CS 209 Data Structure 1. show how to apply a selection sort on {45, 11, 50, 59, 60, 2, 4, 7, 10}. 2. show how to apply a Insertion sort on {45, 11, 50, 59, 60, 2, 4, 7, 10}. 3. show how to apply a Bubble sort on {45, 11, 50, 59, 60, 2, 4, 7, 10}. 4. show how to apply a Merge sort on {45, 11, 50, 59, 60, 2, 4, 7, 10}. 5. show how to...
Make a Frequency Distribution Chart for the following set of Data 50, 10, 25, 20, 20,...
Make a Frequency Distribution Chart for the following set of Data 50, 10, 25, 20, 20, 20, 50,100, 30, 15
Using the following data set: 10, 5, 2, 7, 20, 3, 13, 15, 8, 9 Apply...
Using the following data set: 10, 5, 2, 7, 20, 3, 13, 15, 8, 9 Apply the Merge sort algorithm. [Show to sorting process of the first half only] Apply the Quick sort algorithm [Show the first partitioning implementation]
For the following sample sizes of 100, 50, and 20 I got the following data values....
For the following sample sizes of 100, 50, and 20 I got the following data values. I was asked the proportion of x students on a assingment with a vairiety of test scores. It asked for the proportion of students getting higher than a 69 and 90. The population mean : 83.516 Sample of 100 mean = 81.91 Sample of 50 = 81.74 Sample of 20 = 84.05 for above 69 i got the following proportions Population proportion = .886...
Given the data {20, 20, 30, 30, 40, 40, 50, 50, 60, 60}, calculate 1. Gini...
Given the data {20, 20, 30, 30, 40, 40, 50, 50, 60, 60}, calculate 1. Gini coefficient using the quintile distribution. 2. Draw the Lorenz curve with proper labels.
Which of the following is correct? Select one: a. The data set 100, 200, 300 has...
Which of the following is correct? Select one: a. The data set 100, 200, 300 has the same variance as the data set 150, 250, 350. b. If two data sets have the same range, both sets will have the same interquartile range. c. Pie and bar charts are graphical techniques for nominal data. The former focuses the attention on the frequency of the occurrences of each category, and the latter emphasizes the proportion of occurrences of each category d....
Import a data set (txt file) then do the sorting algorithm using bubble sort, radix sort,...
Import a data set (txt file) then do the sorting algorithm using bubble sort, radix sort, insertion sort, and merge sort, It must show how long it took and how many movements occurred. Please write codes in C++ Here's data set (should be stored in txt file) 7426 4524 4737 9436 3997 2757 6288 5414 9590 5968 6638 3199 9514 1541 9866 2144 6731 911 2171 6135 6437 912 9417 2662 6606 6349 707 2890 5386 9718 3492 5068 9674...
Import a data set (txt file) then do the sorting algorithm using quick sort, shell sort,...
Import a data set (txt file) then do the sorting algorithm using quick sort, shell sort, and selection sort. It must show how long it took and how many movements occurred. Please write codes in C++ Here's data set (should be stored in txt file) 7426 4524 4737 9436 3997 2757 6288 5414 9590 5968 6638 3199 9514 1541 9866 2144 6731 911 2171 6135 6437 912 9417 2662 6606 6349 707 2890 5386 9718 3492 5068 9674 8578 8323...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT