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

How many adjacent swaps does bubble sort (ascending) make on [97, 9, 32, 5, 21, 45, 53, 34]?

  1. A. 13
  2. B. 12
  3. C. 14
  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