Which of the following searching algorithm is fastest when the input array is sorted but has non uniformly distributed values?

Which of the following searching algorithm is fastest when the input array is sorted but has non uniformly distributed values?
A. jump search
B. linear search
C. binary search
D. interpolation search
 
Answer: c
Explanation: Interpolation search has a time complexity of O(n) when the array does not have uniformly distributed values. So in such a case binary search has the least time complexity out of the given options.
 

Tìm kiếm

Back
Top