1.

What is the best case time complexity of bogosort?(a) O(n^2)(b) O(n)(c) O(n log n)(d) O(1)The question was asked in an international level competition.My question is based upon Sorting in portion Sorting of Data Structures & Algorithms II

Answer»

Correct ANSWER is (b) O(n)

Easiest explanation - Best case TIME complexity of BOGOSORT occurs when the input ARRAY is already sorted. So in such a case we only need to check whether all the elements are sorted which can be done in O(n) time.



Discussion

No Comment Found

Related InterviewSolutions