Question:

How many passes are required to sort a list of 6 elements using bubble sort?

Show Hint

For any comparison sorting algorithm like Bubble Sort or Selection Sort, sorting \(n\) elements requires at most \(n - 1\) complete passes.
Updated On: Sep 7, 2026
  • 5
  • 6
  • 4
  • 3
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Concept:
Bubble Sort is an elementary comparison-based sorting algorithm.
It works by repeatedly stepping through the list, comparing adjacent elements, and swapping them if they are in the incorrect order.

Step 1: Determining the Number of Passes in Bubble Sort:

In a standard bubble sort implementation on an array of size \(n\):
- During pass 1, the largest element settles at its correct final position at the end of the array.
- During pass 2, the second largest element settles into the second-to-last position.
- In general, after \(k\) passes, the \(k\) largest elements are guaranteed to be in their final sorted positions.
When \(n - 1\) elements have been systematically placed into their correct positions, the remaining single element is naturally positioned correctly.

Step 2: Calculation for \(n = 6\):

Here, the number of elements is: \[ n = 6 \] The required maximum number of passes is given by the formula: \[ \text{Number of passes} = n - 1 \] Substituting \(n = 6\): \[ \text{Number of passes} = 6 - 1 = 5 \] Final Answer:
Hence, 5 passes are required to sort the list of 6 elements. The correct option is (A).
Was this answer helpful?
0
0