• retagged by
549 views
2 2 votes

$\text { What will be the maximum value returned by function fun? }$

int fun(start, end) {
    len = end - start + 1;
    
    if (len < 1 || end < 0 || start < 0)
        return 0;
        
    if (len % 3 == 0)
        return fun(start + 1, end);
        
    else if (len % 3 == 1)
        return 1 + fun(start, end - 1);
        
    else
        return fun(start + 2, end);
}

1 Answer

Answer:
Position:
Show:

Related questions

2 2 votes
2 2 answers
640
640 views
GO Classes asked Feb 10
640 views
$\text { Consider the following program : }$int main( ) { int *ptr, a, b, c; a = 5; b = 11; c = 20; ptr = &a; *ptr = c; ptr = &c; a = *(&b); c = *ptr - a; printf("%d", c)...
1 1 vote
2 2 answers
834
834 views
GO Classes asked Feb 10
834 views
$\text{P1:}$int a = 5; int main() { int a = 7; return 0; }$\text{P2:}$int main() { int a = 5; int a = 7; return 0; }$\text{P3:}$int main() { int a...
2 2 votes
1 1 answer
642
642 views
GO Classes asked Feb 10
642 views
In Run Time Environment, which of the following is stored in heap?Static variables declared inside a function. Dynamic allocated array of integers created using malloc. R...
6 6 votes
3 3 answers
2.0k
2.0k views
GO Classes asked Feb 13
1,990 views
Given that Maximum Segment size is $2 ~\mathrm{KB}$ and the slow start threshold (ssthresh) is $16 ~\mathrm{KB}$, how many transmission round is required to reach in cong...