Question

Use the routine below to: Identify the base case and the code that is executed when...

Use the routine below to:

  • Identify the base case and the code that is executed when it is true.
  • Identify the general case and the code that is executed when it is true.
  • State what is returned by this routine of its inputs x and y.

Routine

int Test(int x, int y)

{

if (y == 0)

            return 1;

else

            return x * Power(x, y-1);

}

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

Identify the base case and the code that is executed when it is true.

need to pass some values without that it will throw an error.

Identify the general case and the code that is executed when it is true.

it will return power to value of x if Test(0,0) is passed then return value will be 1

State what is returned by this routine of its inputs x and y.

if value of y is 0 then it will return 1 else it will power to x values and return that value

eg Test(2,0) will return 1
eg Test(4,2) will return 16 (4x4)

if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)

Add a comment
Know the answer?
Add Answer to:
Use the routine below to: Identify the base case and the code that is executed when...
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