Vidyalelo
Data Structure · Q236

Dynamic Programming in Data Structures

Programming · Data Structure · question 236

Q236

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

A.
O(n2)
B.
O(1)
Answer
C.
O(n3)
D.
O(n)

Answer: Option B

Solution

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