Question
What will be the status of the following list after the fourth pass of bubble sort and fourth pass of selection sort used for arranging the following elements in descending order?
14, 10, –12, 9, 15, 35
Solution
Bubble Sort
Original Content
14 | 10 | 12 | 9 | 15 | 35 | |
(i) | 14 | 10 | 9 | 15 | 35 | 12 |
(ii) | 14 | 10 | 15 | 35 | 9 | 12 |
(iii) | 14 | 15 | 35 | 10 | 9 | 12 |
(iv) | 15 | 35 | 14 | 10 | 9 | 12 |
Unsorted status after 4th pass
Selection Sort
14 | 10 | 12 | 9 | 15 | 35 | |
(i) | 35 | 10 | 12 | 9 | 15 | 14 |
(ii) | 35 | 15 | 12 | 9 | 10 | 14 |
(iii) | 35 | 15 | 14 | 9 | 10 | 12 |
(iv) | 35 | 15 | 14 | 10 | 9 | 12 |