advertisement
var adpushup = window.adpushup || {};
adpushup.que = adpushup.que || [];
adpushup.que.push(function () {
if (adpushup.config.platform === "MOBILE") {
adpushup.triggerAd("e25be634-2f62-4ed5-978b-3aaec04c8aca");
} else if ((window.outerWidth <= 768) || (window.outerWidth == 0)) {
adpushup.triggerAd("e25be634-2f62-4ed5-978b-3aaec04c8aca");
}
});
#include<stdio.h>
int max_num(int a,int b)
{
if(a> b)
return a;
return b;
}
int maximum_subarray_sum(int *arr, int len)
{
int sum[len], idx;
sum[0] = arr[0];
for(idx = 1; idx < len; idx++)
sum[idx] = _______________________;
int mx = sum[0];
for(idx = 0; idx < len; idx++)
if(sum[idx] > mx)
mx =sum[idx];
return mx;
}
int main()
{
int arr[] = {-2, -5, 6, -2, 3, -1, 0,-5, 6}, len = 9;
int ans = maximum_subarray_sum(arr, len);
printf("%d",ans);
return 0;
}
a) max_num(sum[idx – 1] + arr[idx], arr[idx])
b) sum[idx – 1] + arr[idx].
c) min_num(sum[idx – 1] + arr[idx], arr[idx])
d) arr[idx].
Which line should be inserted in the blank to complete the following dynamic programming implementation of the maximum s
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Which line should be inserted in the blank to complete the following dynamic programming implementation of the maximum s
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!