Question
Computer Science Question on Sorting
What will be the result after pass 2 using Bubble Sort, if we are sorting elements in ascending order?
Initial List: 7 19 18 9 23 51 12 54 73
A
7, 18, 19, 9, 23, 12, 51, 54, 73
B
7, 9, 18, 19, 12, 23, 51, 54, 73
C
7, 9, 19, 18, 12, 23, 51, 54, 73
D
7, 9, 18, 19, 23, 51, 12, 54, 73
Answer
7, 9, 18, 19, 23, 51, 12, 54, 73
Explanation
Solution
In Bubble Sort, after two passes, the list becomes: 7, 9, 18, 19, 23, 51, 12, 54, 73.