1.

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)The question was posed to me during an interview for a job.My question comes from Miscellaneous in division Miscellaneous of Data Structures & Algorithms II

Answer»

Correct OPTION is (a) O(√n)

Best 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.



Discussion

No Comment Found

Related InterviewSolutions