Total how many iterations are required to find the sum of elements in a given range of (l,r) in an array of size n when we use square root optimization?
Total how many iterations are required to find the sum of elements in a given range of (l,r) in an array of size n when we use square root optimization? Correct Answer 3*√n
After calculating the sum of each chunk individually we require to iterate only 3*√n times to calculate the sum in the worst case. It is because two of the √n factors consider the worst case time complexity of summing elements in the first and last block. Whereas the third √n considers the factor of summing the √n chunks.
মোঃ আরিফুল ইসলাম
Feb 20, 2025