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

How many swaps does bubble sort (adjacent swaps, ascending) make on [44, 48, 59, 38, 4, 32, 49]?

  1. A. 12
  2. B. 14
  3. C. 18
  4. D. 13

Correct answer: A. 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