GATE CS 2016, set 2 · Question 47 · Programming and Data Structures · Numerical answer (NAT) · 2 marks · no negative marks
Consider the following program:
int f(int *p, int n) { if (n <= 1) return 0; else return max(f(p+1,n-1),p[0]-p[1]); } int main() { int a[] = {3,5,2,6,4}; printf("%d", f(a,5)); }
Note: max(x,y) returns the maximum of x and y.
The value printed by this program is ______.
Answer
Answer 3
Answer from the official GATE CS 2016 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes