[Solved] efficiency and inefficiency of recursion methods in java [closed]


It depends on the size of the objects you are recursing.

If you are doing recursion over objects that are already in memory, memory impact will be neglible because it’s simply using the same objects that are already in memory over and over. Just see which objects/variables you can re-use to keep memory footprint low.

If you are recursing over directories/files etc.. and constantly loading stuff from disc or database that is not in memory yet, it can become very expensive to do so because of the loading, allocating and then processing.

It all depends on what you really are doing… and you haven’t provided much detail.

solved efficiency and inefficiency of recursion methods in java [closed]