Question

The code for a recursive function 'mystery' appears below. Assume we passed the following array as...

The code for a recursive function 'mystery' appears below.

Assume we passed the following array as x[]:

int x[] = { 10, 20, 25, 25 };

How would we call mystery() so the return value is 1?

int mystery(const int x[], int n, int mysteryValue)
{
   int count = 0;

   if (n <= 0)
      return 0;
   else
   {
      if (x[n - 1] == mysteryValue)
         count = 1;

      return mystery(x, n - 1, mysteryValue) + count;
   }
}

1mystery(x, 4, 0)

2mystery(x, 4, 25)

3mystery(x, 4, 1)

4mystery(x, 4, 20)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

OPTION D IS CORRECT

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
The code for a recursive function 'mystery' appears below. Assume we passed the following array as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT