What will be the output list after completing first pass of bubble sort on…

2022

What will be the output list after completing first pass of bubble sort on input array 32, 51, 27, 85, 66, 23, 13, 57 ?

Answer: A. 32, 27, 51, 66, 23, 13, 57, 85After the first pass, the largest element (85) has been swapped repeatedly until it reached the final index. Here is the trace: (32, 51) → No swap. (51, 27) →…

  1. A.

    32, 27, 51, 66, 23, 13, 57, 85

  2. B.

    32, 51, 27, 66, 23, 13, 57, 8

  3. C.

    27, 33, 51, 23, 13, 57, 66, 85

  4. D.

    23, 13, 27, 33, 51, 57, 66, 85

Attempted by 684 students.

Show answer & explanation

Correct answer: A

After the first pass, the largest element (85) has been swapped repeatedly until it reached the final index. Here is the trace:

  1. (32, 51) → No swap.

  2. (51, 27) → Swap: 32, 27, 51, 85...

  3. (51, 85) → No swap.

  4. (85, 66) → Swap: 32, 27, 51, 66, 85, 23...

  5. (85, 23) → Swap: 32, 27, 51, 66, 23, 85, 13...

  6. (85, 13) → Swap: 32, 27, 51, 66, 23, 13, 85, 57...

  7. (85, 57) → Swap: 32, 27, 51, 66, 23, 13, 57, 85.

Explore the full course: Rssb Basic Computer Instructor

Loading lesson…