Master Mathematics.

Programming · Hard · Searching, Sorting & Complexity · Problem 2

Comparisons on a nearly sorted array

Sort ascending. Let be the number of comparisons made by Bubble Sort and by Insertion Sort. Which options are correct?

  1. (A) ,
  2. (B)
  3. (C) IS on P will perform only one swap
  4. (D) Both BS and IS on P will make at least one unnecessary comparison (comparing elements already in correct order)

Source: GATE DA