In the following list, bubble sort technique has been applied to sort a list of elements.
numList2 = [8, 7, 6, 5, 4]
Arrange the list after each pass in order :
(A) [7, 6, 5, 4, 8]
(B) [5, 4, 6, 7, 8]
(C) [8, 7, 6, 5, 4]
(D) [6, 5, 4, 7, 8]
In the following list, bubble sort technique has been applied to sort a list of elements.
numList2 = [8, 7, 6, 5, 4]
Arrange the list after each pass in order :
(A) [7, 6, 5, 4, 8]
(B) [5, 4, 6, 7, 8]
(C) [8, 7, 6, 5, 4]
(D) [6, 5, 4, 7, 8]
Solution
Bubble sort compares adjacent elements and swaps them if they are in the wrong order. After each pass, the largest remaining element settles at the end.
(C) [8, 7, 6, 5, 4]: the original list, before any pass.
(A) [7, 6, 5, 4, 8]: after pass 1, 8 has moved to the end.
(D) [6, 5, 4, 7, 8]: after pass 2, 7 has moved to its place.
(B) [5, 4, 6, 7, 8]: after pass 3, 6 has moved to its place.
After pass 4 the list becomes [4, 5, 6, 7, 8].
Related questions:
2026: 29 May Shift 2
2025: 22 May Shift 1
2026: 21 May Shift 1
2026: 23 May Shift 2