Consider the problem of sorting the given array in ascending order:
P = [1, 2, 3, 5, 4]Consider two sorting algorithms Bubble Sort (BS) and Insertion Sort (IS).
Let N1 be the total number of comparisons done by BS on the elements of P and N2 be the total number of comparisons done by IS on the elements of P.
Which of the following options is/are correct?
- (A)
N1 = 10, N2 = 4
- (B)
N1 > N2
- (C)
IS on P will perform only one swap
- (D)
Both BS and IS on P will make at least one unnecessary comparison (i.e., comparing elements that are already in correct order)
