Question

a) Consider an algorithm for determining the size of some nested folders/les recursively. (Imagine right clicking...

a) Consider an algorithm for determining the size of some nested folders/les recursively. (Imagine right clicking an item on your desktop and viewing it's size.) What would be the base case(s) for this problem?

b) Consider the problem of reversing letters of a string. Would it be more appropriate to use recursion or iteration? Justify your answer. [8 points] Short Answer:

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

a) The Base case would be if the given artifact is a file. In case of a file, The overall size is of file only, and only that need to be returned..
While in case of folder, All the folders inside and their file sizes should be added.

b)
Iteration is a better approach.. Since in case of recursion, Program stack gets used.. So if there is a very long string, we may get StackOverflow exception, Which can be avoided in case of Using an iterative approach.

Add a comment
Know the answer?
Add Answer to:
a) Consider an algorithm for determining the size of some nested folders/les recursively. (Imagine right clicking...
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