gs gs122 Dynamic Programming - Matrix-chain Multiplication - Quiz No.1
gs gs122 Data Communication and Computer Network Quiz
This quiz belongs to book/course code gs gs122 Data Communication and Computer Network of gs organization. We have 268 quizzes available related to the book/course Data Communication and Computer Network. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Dynamic Programming. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
#include<stdio.h> #include<limits.h> int mat_chain_multiplication(int *mat, int n) { int arr[n][n]; int i,k,row,col,len; for(i=1;i<n;i++) arr[i][i] = 0; for(len = 2; len < n; len++) { for(row = 1; row <= n - len + 1; row++) { col = row + len - 1; arr[row][col] = INT_MAX; for(k = row; k <= col - 1; k++) { int tmp = ________________________; if(tmp < arr[row][col]) arr[row][col] = tmp; } } } return arr[1][n - 1]; } int main() { int mat[6] = {20,5,30,10,40}; int ans = mat_chain_multiplication(mat,5); printf("%d",ans); return 0; }
Which of the following lines should be inserted to complete the above code?