What Will Be The Output Of The Following Codep Pre Langc #417

What will be the output of the following code?</p> <pre><code class="language-c"> #include <bits/stdc++.h> using namespace std; int min(int x, int y) { return (x < y)? x: y; } int func(int arr[], int n) { int *jump = new int[n]; int i, j; if (n == 0 || arr[0] == 0) return INT_MAX; jump[0] = 0; for (i = 1; i < n; i++) { jump[i] = INT_MAX; for (j = 0; j < i; j++) { if (i <= j + arr[j] && jump[j] != INT_MAX) { jump[i] = min(jump[i], jump[j] + 1); break; } } } return jump[n-1]; } int main() { int arr[] = {1, 3, 6, 1, 9,7}; int size = sizeof(arr)/sizeof(int); cout<< func(arr,size); return 0; } </code></pre>

Online Quiz This multiple choice question (MCQ) is related to the book/course gs gs121 Data Structures and Algorithms. It can also be found in gs gs121 Array Types - Number of Jumps to Reach End-array Operation - Quiz No.1.


Similar question(s) are as followings:



Online Quizzes of gs121 Data Structures and Algorithms

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background