Vidyalelo
Data Structure · Q151

Dynamic Programming in Data Structures

Programming · Data Structure · question 151

Q151

What is the value stored in ans[3][3] when the following code is executed? #include int balanced_partition(int *arr, int len) int sm = 0, i, j; for(i = 0;i = arr[j - 1]) ans[i][j] = ans[i][j] || ans[i - arr[j - 1]][j - 1]; return ans[sm/2][len]; int main() int arr[] = 3, 4, 5, 6, 7, 1, len = 6; int ans = balanced_partition(arr,len); if(ans == 0) printf("false"); else printf("true"); return 0;

A.
0
B.
1
Answer
C.
-1
D.
-2

Answer: Option B

Solution

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