Home / MCQ Bank / Computer
Computer Dynamic Programming In Data Structures

Which line should be inserted in the blank to complete the following dynamic programming implementation of the maximum sub-array sum problem? #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; }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option A • max_num(sum[idx - 1] + arr[idx], arr[idx])

Related Computer Questions

In NiFi, what is the function of the "ExecuteStreamCommand" processor? Which of the following is the communication protocol that sets the standard used by every computer that accesses Web-based information? What is the process of gathering data from various sources and storing it for analysis known as? The Josephson tunneling device illustrates principles associated with the advanced storage technique: The server is told to accept spaces after function names by ______