Open In App

Algorithms | Divide and Conquer | Question 4

Like Article
Like
Save
Share
Report

Maximum Subarray Sum problem is to find the subarray with maximum sum. For example, given an array {12, -13, -5, 25, -20, 30, 10}, the maximum subarray sum is 45. The naive solution for this problem is to calculate sum of all subarrays starting with every element and return the maximum of all. We can solve this using Divide and Conquer, what will be the worst case time complexity using Divide and Conquer?

(A)

O(n)

(B)

O(nLogn)

(C)

O(Logn)

(D)

O(n^2)


Answer: (B)

Explanation:

See http://www.geeksforgeeks.org/divide-and-conquer-maximum-sum-subarray/


Quiz of this Question
Please comment below if you find anything wrong in the above post


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads