English

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. - Computer Science (Python)

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 Note

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
  Is there an error in this question or solution?
Chapter 5: Sorting - Exercise [Page 79]

APPEARS IN

NCERT Computer Science [English] Class 12
Chapter 5 Sorting
Exercise | Q 2. | Page 79
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×