Question:

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

Updated On: May 28, 2025
  • 7, 18, 19, 9, 23, 12, 51, 54, 73
  • 7, 9, 18, 19, 23, 51, 12, 54, 73
  • 7, 9, 19, 18, 12, 23, 51, 54, 73
  • 7, 9, 18, 19, 12, 23, 51, 54, 73
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Approach Solution - 1

To solve this problem, we need to apply Bubble Sort, a simple sorting algorithm where each pass through the list involves comparing adjacent elements and swapping them if they are in the wrong order. We'll explain the process for the initial list:

Initial List: 7, 19, 18, 9, 23, 51, 12, 54, 73

Pass 1:

  • Compare 7 and 19: No swap needed.
  • Compare 19 and 18: Swap (Result: 7, 18, 19, 9, 23, 51, 12, 54, 73).
  • Compare 19 and 9: Swap (Result: 7, 18, 9, 19, 23, 51, 12, 54, 73).
  • Compare 19 and 23: No swap needed.
  • Compare 23 and 51: No swap needed.
  • Compare 51 and 12: Swap (Result: 7, 18, 9, 19, 23, 12, 51, 54, 73).
  • Compare 51 and 54: No swap needed.
  • Compare 54 and 73: No swap needed.

List after Pass 1: 7, 18, 9, 19, 23, 12, 51, 54, 73

Pass 2:

  • Compare 7 and 18: No swap needed.
  • Compare 18 and 9: Swap (Result: 7, 9, 18, 19, 23, 12, 51, 54, 73).
  • Compare 18 and 19: No swap needed.
  • Compare 19 and 23: No swap needed.
  • Compare 23 and 12: Swap (Result: 7, 9, 18, 19, 12, 23, 51, 54, 73).
  • Compare 23 and 51: No swap needed.
  • Compare 51 and 54: No swap needed.
  • Compare 54 and 73: No swap needed.

List after Pass 2: 7, 9, 18, 19, 12, 23, 51, 54, 73

Therefore, the result after Pass 2 using Bubble Sort in ascending order is: 7, 9, 18, 19, 12, 23, 51, 54, 73.

Was this answer helpful?
0
0
Hide Solution
collegedunia
Verified By Collegedunia

Approach Solution -2

The result after pass 2 of Bubble Sort will be 7, 9, 18, 19, 12, 23, 51, 54, 73.

Additional Context:

  • Initial List: 7, 19, 18, 9, 23, 51, 12, 54, 73
  • Pass 1 (Largest element sorted):
    • Comparisons: 7-19, 19-18, 19-9, 19-23, 23-51, 51-12, 51-54, 54-73
    • Swaps: 19↔18, 19↔9, 51↔12
    • Result: 7, 18, 9, 19, 23, 12, 51, 54, 73
  • Pass 2 (Second largest sorted):
    • Comparisons: 7-18, 18-9, 18-19, 19-23, 23-12, 23-51, 51-54
    • Swaps: 18↔9, 23↔12
    • Final after Pass 2: 7, 9, 18, 19, 12, 23, 51, 54, 73
  • Key Observations:
    • Each pass places the next largest element correctly
    • 54 and 73 were already in position

Correct Answer: (4) 7, 9, 18, 19, 12, 23, 51, 54, 73.

Was this answer helpful?
0
0