Consider The Following Dynamic Programming Implementation Of #2184
Consider the following dynamic programming implementation of the dice throw problem:</p> <pre><code class="language-c"> #include<stdio.h> int get_ways(int num_of_dice, int num_of_faces, int S) { int arr[num_of_dice + 1][S + 1]; int dice, face, sm; for(dice = 0; dice <= num_of_dice; dice++) for(sm = 0; sm <= S; sm++) arr[dice][sm] = 0; for(sm = 1; sm <= S; sm++) arr[1][sm] = 1; for(dice = 2; dice <= num_of_dice; dice++) { for(sm = 1; sm <= S; sm++) { for(face = 1; face <= num_of_faces && face < sm; face++) arr[dice][sm] += arr[dice - 1][sm - face]; } } return _____________; } int main() { int num_of_dice = 3, num_of_faces = 4, sum = 6; int ans = get_ways(num_of_dice, num_of_faces, sum); printf("%d",ans); return 0; }</code></pre> <p>Which of the following lines should be added to complete the above code?
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 - Dice Throw Problem - Quiz No.1.
Consider the following dynamic programming implementation of the dice throw problem:
#include<stdio.h> int get_ways(int num_of_dice, int num_of_faces, int S) { int arr[num_of_dice + 1][S + 1]; int dice, face, sm; for(dice = 0; dice <= num_of_dice; dice++) for(sm = 0; sm <= S; sm++) arr[dice][sm] = 0; for(sm = 1; sm <= S; sm++) arr[1][sm] = 1; for(dice = 2; dice <= num_of_dice; dice++) { for(sm = 1; sm <= S; sm++) { for(face = 1; face <= num_of_faces && face < sm; face++) arr[dice][sm] += arr[dice - 1][sm - face]; } } return _____________; } int main() { int num_of_dice = 3, num_of_faces = 4, sum = 6; int ans = get_ways(num_of_dice, num_of_faces, sum); printf("%d",ans); return 0; }
Which of the following lines should be added to complete the above code?
arr[num_of_dice][S]
arr[dice][sm]
arr[dice][S]
arr[S][dice]
Similar question(s) are as followings:
Online Quizzes of gs122 Data Communication and Computer Network

Sorting - Insertion Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes

Sorting - Insertion Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes

Sorting - Insertion Sort - Quiz No.3
gs gs122 Data Communication and Computer Network
Online Quizzes

Sorting - LSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes

Sorting - MSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes

Sorting - MSD Radix Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes