Mixed recursions:

We have taken simple example above, There can examples of  recursions also which is neither a head recursion nor a tail recursion. Plus, there can be multiple recursive calls to the function within a function. For example Consider the recursive code to traverse a tree in in-order:

traversal_in.JPG

The recursive call is made at both, the head and tail. such example are difficult to convert to iterative version, because they do not map to a single loop.

Pages: 1 2 3 4

8 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *