Question:medium

If a list contains ’n’ number of elements and all the elements are by default sorted in ascending order, how many comparisons will be required during 1st pass of bubble sort to arrange the list in ascending order?

Updated On: Jan 16, 2026
  • 0
  • 1
  • n - 1
  • n
Show Solution

The Correct Option is C

Solution and Explanation

Bubble Sort operates by iteratively comparing adjacent elements and exchanging them if they are in the incorrect order. In the initial pass, comparisons are made between all elements except the last, as this guarantees the largest element settles at the list's end.

Consider a list containing 'n' elements ordered ascendingly.

  • The 1st pass executes comparisons between the 1st and 2nd elements, then the 2nd and 3rd, continuing until the (n-1)th element is compared with the nth element.
  • Consequently, the 1st pass involves exactly (n-1) comparisons.

Therefore, for a list of 'n' elements, the first pass of Bubble Sort requires n - 1 comparisons.

Was this answer helpful?
0


Questions Asked in CUET (UG) exam