What will be the time complexity of the code to find a minimum element from an array of size n and uses square root decomposition(exclude

What will be the time complexity of the code to find a minimum element from an array of size n and uses square root decomposition(exclude pre processing time)?
A. O(√n)
B. O(n)
C. O(1)
D. O(n$^{2}$)
 
Answer: a
Explanation: For finding the minimum element in a given array of size n using square root decomposition we first divide the array into √n chunks and calculate the result for them individually. So for a given query, the result of middle blocks has to be calculated along with the extreme elements. This takes O(√n) time in the worst case.
 

Tìm kiếm

Back
Top