What is the time complexity of exponential search when the input array is sorted but the values are not uniformly distributed?

What is the time complexity of exponential search when the input array is sorted but the values are not uniformly distributed?
A. O(n$^{1/2}$)
B. O(log log n)
C. O(n)
D. O(log n)
 
Answer: c
Explanation: When an array has non uniformly distributed values then in that case the algorithm of interpolation search fails to work efficiently. As a result, it has a time complexity of O(n) in such a case.
 

Tìm kiếm

Back
Top