1.

What will be the worst case time complexity of code to find sum in given query range (l,r) in an array of size n with q number of such queries when we apply MO’s algorithm?(a) O(n*q)(b) O(n)(c) O((q+n)√n)(d) O(q*√n)The question was asked in an interview for internship.This question is from Miscellaneous in portion Miscellaneous of Data Structures & Algorithms II

Answer»

Correct option is (C) O((q+N)√n)

For explanation: MO’s ALGORITHM requires O(q*√n) + O(n*√n) time for processing all the QUERIES. It is better than the naive solution where O(n*q) time is required.



Discussion

No Comment Found

Related InterviewSolutions