Vidyalelo
Data Structure · Q107

Dynamic Programming in Data Structures

Programming · Data Structure · question 107

Q107

Consider the following code: #include int balanced_partition(int *arr, int len) int sm = 0, i, j; for(i = 0;i = arr[j - 1]) ans[i][j] = _______________; 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; Which of the following lines should be inserted to complete the above code?

A.
ans[i - arr[j - 1]][j - 1]
B.
ans[i][j]
C.
ans[i][j] || ans[i - arr[j - 1]][j - 1]
Answer
D.
ans[i][j] && ans[i - arr[j - 1]][j - 1]

Answer: Option C

Solution

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