Advertisements
Advertisements
Question
Identify the number of swaps required for sorting the following list using selection sort and bubble sort and identify which is the better sorting technique with respect to the number of comparisons.
List 1:
| 63 | 42 | 21 | 9 |
Short/Brief Note
Advertisements
Solution
Number of swaps required for sorting the following list using selection sort: 3
Number of swaps required for sorting the following list using bubble sort: 6
Selection sort performs less swaps than bubble sort; as a result, despite the fact that both sorting methods are O(N2), selection sort is faster and more effective.
shaalaa.com
Bubble Sort in Python
Is there an error in this question or solution?
