Question

Hello, i am not sure on how to work this out, can you explain and show how you get the answer? Cheers

The lecture notes show the top 5 levels of the call graph for a call coins_reqd(30, 11, 10, 25]) with a purely recursive impl

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

Detailed explanation of how to do such problems is as follows:

Trace This problem using a stack: call to coins_read(11, [1,5,10]) is made, Create a stack and put all neccesary information

TWITTER follow same procedure till we reach node 5. The time we reach node 5, our stack will look like as follows: (10) T110)

au fob poop in this direction, 5,10] - Assume all falls. travessed as shown above, I now, just pop 15% off one more call for

stack is empty now, we have paversed our complete free, In whole baversal, we get Node is 3 times. Hence, It is called 3 time

Conclusion: Node "5" (yellow node) is called 3 times in this procedure.

Given only tree this was the most visualized way to solve this problems, it we would have given the recursion, then there are other ways to solve such kind of problems.

But this is the best way if you want to visualize things.

I have drawn stack horizontally, just to save space, don't confuse it with the queue. It's a stack.

Pardon my handwriting, i would have typed this answer if possible, but i needed to draw these stack instances.

If you still got any doubt in the explanation, lemme know in the comment section.

Add a comment
Know the answer?
Add Answer to:
Hello, i am not sure on how to work this out, can you explain and show...
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
Active Questions
ADVERTISEMENT