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

How many swaps does bubble sort (adjacent swaps, ascending) make on [57, 4, 11, 32, 51, 42, 56, 24]?

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

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