Recursion is a powerful technique for producing simple algorithms. It can be used to handle data-intensive operations, such as processing network management data. In this article, I use recursion to handle the processing of nested data elements from a network management application. This is just one domain where this approach can be used.
Recursive solutions are sometimes rejected based on unfounded fears concerning infinite loops or poor performance. In reality, recursive solutions can be highly elegant, easy to implement, and easy to maintain. This article shows an example of a recursive C++ solution as well as a description of the tradeoffs, advantages, and disadvantages of this important design technique.
Here’s my software design philosophy: if it’s simple, it works, it’s reasonably efficient, and it’s maintainable, it’s good code!
As usual, let’s now get the background information out of the way!