Computer Science EngineeringVery hard

After one complete left-to-right bubble sort pass over [5, 1, 4, 2, 8], the array is

  1. A. 1 4 2 5 8
  2. B. 1 5 4 2 8
  3. C. 1 2 4 5 8
  4. D. 1 4 2 8 5

Correct answer: A. 1 4 2 5 8

5 is swapped past 1, 4 and 2, then compared with 8 and stays, leaving 1 4 2 5 8.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic