What Is The Output Of The Following Codep Pre Langc #2175

What is the output of the following code?</p> <pre><code class="language-c"> #include<stdio.h> int balanced_partition(int *arr, int len) { int sm = 0, i, j; for(i = 0;i < len; i++) sm += arr[i]; if(sm % 2 != 0) return 0; int ans[sm/2 + 1][len + 1]; for(i = 0; i <= len; i++) ans[0][i] = 1; for(i = 1; i <= sm/2; i++) ans[i][0] = 0; for(i = 1; i <= sm/2; i++) { for(j = 1;j <= len; j++) { ans[i][j] = ans[i][j-1]; if(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[] = {5, 6, 7, 10, 3, 1}, len = 6; int ans = balanced_partition(arr,len); if(ans == 0) printf("false"); else printf("true"); return 0; }</code></pre>

Online Quiz This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Dynamic Programming - Balanced Partition - Quiz No.2.


Similar question(s) are as followings:



Online Quizzes of gs122 Data Communication and Computer Network

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background