+1 vote
in Data Structures & Algorithms II by (110k points)
Any algorithm that sorts by exchanging adjacent elements require O(N^2) on average.

(a) True

(b) False

This question was posed to me during an interview.

My doubt stems from Insertion sort topic in portion Sorting of Data Structures & Algorithms II

1 Answer

+1 vote
by (614k points)
selected by
 
Best answer
Correct answer is (a) True

To explain: Each swap removes only one inversion, so O(N^2) swaps are required.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...