Question: FindMaxSubarraySum ( A , low, high ) if high = = low then return A [ low ] end if mid = ( low +

FindMaxSubarraySum(A, low, high) if high == low then return A[low] end if mid =(low + high)/2 leftMaxSum = FindMaxSubarraySum(A, low, mid) rightMaxSum = FindMaxSubarraySum() crossMaxSum FindMaxCrossSubarraySum(A, low, mid, high) ans max (,, crossMaxSum) return ans FindMaxCrossSubarraySum(A, low, mid, high) maxSuffixSum 4 suffixSum 0 for i mid downto low do suffixSum suffixSum + A[i] if suffixSum > maxSuffixSum then maxSuffixSum suffixSum end if end for maxPrefixSum prefixSum 0 for i mid +1 to high do prefixSum prefixSum + if prefixSum > maxPrefixSum then maxPrefixSum prefixSum end if end for crossMaxSum maxSuffixSum + maxPrefixSum return crossMaxSum Analyze the running time T(n) of the algorithm, you can assume n is a power of 2 FindMaxSubarraySum(A, low, high) if high == low then return A[low] end if mid =(low + high)/2 leftMaxSum = FindMaxSubarraySum(A, low, mid) rightMaxSum = FindMaxSubarraySum() crossMaxSum FindMaxCrossSubarraySum(A, low, mid, high) ans max (,, crossMaxSum) return ans FindMaxCrossSubarraySum(A, low, mid, high) maxSuffixSum 4 suffixSum 0 for i mid downto low do suffixSum suffixSum + A[i] if suffixSum > maxSuffixSum then maxSuffixSum suffixSum end if end for maxPrefixSum prefixSum 0 for i mid +1 to high do prefixSum prefixSum + if prefixSum > maxPrefixSum then maxPrefixSum prefixSum end if end for crossMaxSum maxSuffixSum + maxPrefixSum return crossMaxSum Analyze the running time T(n) of the algorithm, you can assume n is a power of 2 to simply the analysis: T(n)= T( n 2)+(4) The total running time of this algorithm is in .to simply the analysis: T(n)= T( n 2)+(4) The total running time of this algorithm is in .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!