Thursday, May 17, 2007

Recursion is hard

Recursion is hard. People keep saying that all over internet, but one really cannot develop an appreciation of how hard it really is until there is a problem in your code that's related to recursion.
I'm currently solving such a problem. The handheld code I wrote for a tree-like data structure is returning the wrong result. Why? Because, although I thought I was explicitly clear on what process should the intermediate result follow, it seems that through unwinding of the recursion call, a piece of my code simply ignores that result and it goes on checking other nodes and leaves. If these latter nodes and leaves return a positive intermediate result, my code seems to just run with it and therefore breaking functionality.

Recursion is hard.

Srki

P.S. This is my first blog post. I love it.