1.

What is the worst case time complexity of cocktail sort?(a) O(n)(b) O(n log n)(c) O(n^2)(d) O(log n)I have been asked this question during a job interview.I would like to ask this question from Sorting in chapter Sorting of Data Structures & Algorithms II

Answer»

Right CHOICE is (c) O(n^2)

EXPLANATION: Worst case COMPLEXITY is observed when the input array is reverse SORTED. This is the same as the worst case complexity of bubble sort.



Discussion

No Comment Found

Related InterviewSolutions