Vidyalelo
Data Structure · Q294

Dynamic Programming in Data Structures

Programming · Data Structure · question 294

Q294

What is the output of the following naive method used to find the maximum sub-array sum? #include int main() int arr[1000] = -2, -5, 6, -2, 3, -1, 0,-5, 6, len = 9; int cur_max, tmp_max, strt_idx, sub_arr_idx; cur_max = arr[0]; for(strt_idx = 0; strt_idx cur_max) cur_max = tmp_max; printf("%d",cur_max); return 0;

A.
6
B.
9
C.
7
Answer
D.
4

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board