Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE

How many swaps does bubble sort (adjacent swaps, ascending) make on [45, 37, 10, 17, 54, 53, 2]?

  1. A. 14
  2. B. 12
  3. C. 9
  4. D. 11

Correct answer: B. 12

Each adjacent swap removes exactly one inversion, so swaps = number of inversions = 12.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic