1.

What is the best case time complexity of quickselect?(a) O(n log n)(b) O(n^2)(c) O(n)(d) O(log n)I got this question in final exam.This is a very interesting question from Miscellaneous in portion Miscellaneous of Data Structures & Algorithms II

Answer»

The correct OPTION is (c) O(n)

Easiest explanation - Best case TIME COMPLEXITY of QUICKSELECT is O(n). It is observed in the case where good pivots are chosen CONSISTENTLY then the array size decreases exponentially and thus the required element is found in linear time.



Discussion

No Comment Found

Related InterviewSolutions