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:
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.
a) Consider an algorithm for determining the size of some nested folders/les recursively. (Imagine right clicking...
Already been answer on the website, but I didn't understand the answer. I would appreciate a better explanation, thank you: Consider an algorithm in Java for determining the size of some nested folders/files recursively. (Imagine right clicking an item on your desktop and viewing it's size.) What would be the base case(s) for this problem?