InterviewSolution
Saved Bookmarks
| 1. |
What is the average case time complexity of odd-even sort?(a) O(n)(b) O(n log n)(c) O(n^2)(d) O(log n)I had been asked this question in final exam.The doubt is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT CHOICE is (c) O(n^2) For explanation: Cocktail sort takes O(n^2) time on AVERAGE as it KEEPS on applying bubble sort on the elements in TWO phases until they are sorted. This is the same as the average time complexity of bubble sort. |
|