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

How many swaps does bubble sort (adjacent swaps, ascending) make on [33, 25, 8, 52, 16, 15, 22, 24, 10]?

  1. A. 13
  2. B. 27
  3. C. 23
  4. D. 18

Correct answer: C. 23

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

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

Exams that ask this topic