gs gs122 Dynamic Programming - Minimum Number of Jumps - 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 11 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 min_jumps(int *arr, int strt, int end) { int idx; if(strt == end) return 0; if(arr[strt] == 0) // jump cannot be made return INT_MAX; int min = INT_MAX; for(idx = 1; idx <= arr[strt] && strt + idx <= end; idx++) { int jumps = min_jumps(____,____,____) + 1; if(jumps < min) min = jumps; } return min; } int main() { int arr[] ={1, 3, 5, 8, 9, 2, 6, 7, 6},len = 9; int ans = min_jumps(arr, 0, len-1); printf("%d\n",ans); return 0; }
Which of these arguments should be passed by the min_jumps function represented by the blanks?
#include<stdio.h> #include<limits.h> int min_jump(int *arr, int len) { int j, idx, jumps[len]; jumps[len - 1] = 0; for(idx = len - 2; idx >= 0; idx--) { int tmp_min = INT_MAX; for(j = 1; j <= arr[idx] && idx + j < len; j++) { if(jumps[idx + j] + 1 < tmp_min) tmp_min = jumps[idx + j] + 1; } jumps[idx] = tmp_min; } return jumps[0]; } int main() { int arr[] ={1, 1, 1, 1, 1, 1, 1, 1, 1},len = 9; int ans = min_jump(arr,len); printf("%d\n",ans); return 0; }
Which of the following "for" loops can be used instead of the inner for loop so that the output doesn't change?