15 5 18 16 4 9 13 11 What would be the total number of comparisons required to carry out a Selection Sort on this data?
时间: 2024-05-18 16:18:40 浏览: 20
To carry out a Selection Sort on this data, we need to compare each element with all the remaining elements to find the smallest element and swap it with the current element.
For the first element, we need to make 7 comparisons (with 5, 18, 16, 4, 9, 13, and 11).
For the second element, we need to make 6 comparisons (with 18, 16, 4, 9, 13, and 11).
For the third element, we need to make 5 comparisons (with 16, 4, 9, 13, and 11).
For the fourth element, we need to make 4 comparisons (with 9, 13, and 11).
For the fifth element, we need to make 3 comparisons (with 13 and 11).
For the sixth element, we need to make 2 comparisons (with 11).
For the seventh element, we need to make 1 comparison.
So the total number of comparisons required to carry out a Selection Sort on this data would be:
7 + 6 + 5 + 4 + 3 + 2 + 1 = 28
Therefore, 28 comparisons would be required to perform a Selection Sort on this data.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)