ProgrammingHard

Bubble sort on the records of 4 keys {4, 3, 2, 1} with a swap count: how many swaps are made?

  1. A. 6
  2. B. 4
  3. C. 5
  4. D. 3

Correct answer: A. 6

Every pair of the four keys is out of order and is swapped exactly once, and there are C(4,2) = 6 pairs.

More C Programming questions

Exams that ask this topic