TRENDING NEWS

POPULAR NEWS

Draw The Extensive Form Of The Maze In For The Figure Shown And Solve It.

When should programmers use recursion?

I frequently use recursion to do a diagnostic dump on an object. The recursion is needed so that it can work its way down through the objects within the object and so forth. In Java it’s a bit of a chore, mostly because of the odd handling of arrays, so I have some code I wrote a long time ago that I copy and paste then modify to my needs.But extensive recursion?Several years ago I wrote a DBMS in C++ in which the Bayer tree (B-Tree) indexes were comprised of a tree of data structures that would collapse, expand, stack, etc. as needed on any call - be it an add, delete, or an update that changed a key value. Traversing the tree also moved laterally and vertically through it. So pretty much every method/function had to be recursive, and I’m talking about a hundred or more such methods/functions.Since the algorithm is well-documented in many places, it was surprisingly easy to write…once I got my head around it. But it was a bear to debug. I ended up writing a large number of diagnostic functions that were permanently left in the code and that could be enabled or configured via settings without bringing the DBMS down.

TRENDING NEWS